Test of the Java Skill(1)

crazycode007

crazycode007

2016-02-19 18:40

下面图老师小编要跟大家分享Test of the Java Skill(1),简单的过程中其实暗藏玄机,还是要细心学习,喜欢还请记得收藏哦!


     Question 1:
     What will happen when you attempt to compile and run this code?
     class Base{
     public final void amethod(){
     System.out.println(“amethod”);
     }
     }
  
     public class Fin extends Base{
     public static void main(String argv[]){
     Base b = new Base();
     b.amethod();
     }
     }
  
     A. Compile time error indicating that a class with any final methods must be declared final itself
  
     B. Compile time error indicating that you cannot inherit from a class with final methods
  
     C. Run time error indicating that Base is not defined as final
  
     D. SUCcess in compilation and output of “amethod” at run time
  
     Question 2:
     Given the following code what will be output?
  
     public class Pass{
     static int j = 20;
     public static void main(String argv[]){
     int i=10;
     Pass p = new Pass();

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)

   p.amethod(i);
     System.out.println(i);
     System.out.println(j);
     }
  
     public void amethod(int x){
     x=x*2;
     j=j*2;
     }
     }
  
     A. Error: amethod parameter does not match variable
  
     B. 20 and 40
  
     C. 10 and 40
  
     D. 10 and 20
  
     Question 3:
     What happens when you attempt to compile and run these two files in the same Directory?
  
     // File P1.Java
  
     package MyPackage;
     class P1{
     void afancymethod(){
     System.out.println(“what a fancy method”);
     }
     }
  
     // File P2.java
  
     public class P2 extends P1{
     afancymethod();
     }
  
     A. Both compile and P2 outputs “what a fancy method” when run
  
     B. Neither will compile
  
     C. Both compile but P2 has an error at run time
  
     D. P1 compiles cleanly but P2 has an error at compile time
  
     Question 4:
     Which statement declares a variable a which is suitable for
  referring to an array of 50 string objects?
  
     A. char a[][];
  
     B. String a[];
  
     C. String []a;
  
     D. Object a[50];
  
     E. String a[50];
  
     Question 5:
     Given the following declaration
     String s = "Example";
     Which are legal code?
  
     A. s = 3;
  

展开更多 50%)
分享

猜你喜欢

Test of the Java Skill(1)

编程语言 网络编程
Test of the Java Skill(1)

Test of the Java Skill(2)

编程语言 网络编程
Test of the Java Skill(2)

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Test of the Java Skill(4)

编程语言 网络编程
Test of the Java Skill(4)

java_util_test

编程语言 网络编程
java_util_test

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

JAVA入门(1) 什么是JAVA

编程语言 网络编程
JAVA入门(1) 什么是JAVA

Java入门及faq__1(1)

编程语言 网络编程
Java入门及faq__1(1)

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Dreamweaver中sql注入式攻击的防范

Dreamweaver中sql注入式攻击的防范

熟练掌握JDK1.5枚举类型

熟练掌握JDK1.5枚举类型
下拉加载更多内容 ↓