开发学院WEB开发Jsp Test of the Java Skill(1) 阅读

Test of the Java Skill(1)

 2008-01-05 20:29:25 来源:WEB开发网 闂傚倸鍊风欢姘缚瑜嶈灋闁圭虎鍠栫粻顖炴煥閻曞倹瀚�闂傚倸鍊风粈渚€骞夐敓鐘插瀭闁汇垹鐏氬畷鏌ユ煙閹殿喖顣奸柛搴$У閵囧嫰骞掗幋婵冨亾閻㈢ǹ纾婚柟鐐灱濡插牊绻涢崱妤冃℃繛宀婁簽缁辨捇宕掑鎵佹瀸闂佺懓鍤栭幏锟�濠电姷鏁告慨顓㈠箯閸愵喖宸濇い鎾寸箘閹规洟姊绘笟鈧ḿ褍煤閵堝悿娲Ω閳轰胶鍔﹀銈嗗笂閼冲爼鍩婇弴銏$厪闁搞儮鏅涙禒褏绱掓潏鈺佷槐闁轰焦鎹囬弫鎾绘晸閿燂拷闂傚倸鍊风欢姘缚瑜嶈灋闁圭虎鍠栫粻顖炴煥閻曞倹瀚�  闂傚倸鍊烽懗鑸电仚缂備胶绮〃鍛村煝瀹ュ鍗抽柕蹇曞У閻庮剟姊虹紒妯哄闁圭⒈鍋嗛惀顏囶樄闁哄本娲樼换婵婄疀閺囩姷鐛ラ梻浣哄帶婢瑰﹥绂嶅⿰鍫氣偓鏃堝礃椤忎礁浜鹃柨婵嗛婢ь喖霉閻樻瑥瀚粻楣冩煕椤愩倕鏋庨柣蹇嬪劜閵囧嫰寮村Ο鍝勫Е濡炪們鍨洪悷鈺呭箖閳╁啯鍎熼柕鍥у簻閹凤拷
核心提示: Question 1: What will happen when you attempt to compile and run this code? class Base{ public final void amethod(){ System.out.PRintln(“amethod”); } }


   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();

   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;

Tags:Test of the

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接