JAVA模拟题:TestoftheJavaSkill(3)

文章作者 100test 发表时间 2007:03:14 17:03:37
来源 100Test.Com百考试题网


   Question 17:
   What will happen when you attempt to compile and run this code?
   class Base{
   abstract public void myfunc().
   public void another(){
   System.out.println(“Another method”).
   }
   }

   public class Abs extends Base{
   public static void main(String argv[]){
   Abs a = new Abs().
   a.amethod().
   }
   public void myfunc(){
   System.out.println(“My func”).
   }
   public void amethod(){
   myfunc().
   }
   }

   A. The code will compile and run, printing out the words “My func”

   B. The compiler will complain that the Base class is not declared as abstract.

   C. The code will compile but complain at run time that the Base class has non abstract methods

   D. The compiler will complain that the method myfunc in the base class has no body

   Question 18:
   You need to create a class that will store some unique object elements. You do not need to sort these elements but they must be unique.

   What interface might be most suitable to meet this need?

   A. Set

   B. List

   C. Map

   D. Vector

   Question 19:
   What will happen when you attempt to compile and run the following code?

   class Background implements Runnable{
   int i = 0.
   public int run(){
   while(true){
   i .
   System.out.println(“i=” i).
   }//End while
   }//End run
   }//End class

   A. It will compile and the run method will print out the increasing value of i

   B. It will compile and calling start will print out the increasing value of i

   C. The code will cause an error at compile time

   D. Compilation will cause an error because while cannot take a parameter of true

   Question 20:
   Given the following code how could you invoke the Base constructor that will print out the string “base constructor”?
   class Base{
   Base (int i){
   System.out.println(“base constructor”).
   }
   Base(){
   }
   }

   public class Sup extends Base{
   public static void main(String argv[]){
   Sup s = new Sup().
   // One
   }
   Sup(){
   // Tow
   }
   public void derived(){
   // Three
   }
   }

   A. On the line After // One put Base(10).

   B. On the line After // One put super(10).

   C. On the line After // Two put super(10).

   D. On the line After // Three put super(10).


相关文章


JAVA模拟题:TestoftheJavaSkill(1)
JavaSE6.0桌面API编程 (中)
JAVA基础:利用Java实现zip压缩解压缩
JavaSE6.0桌面API编程 (上)
JAVA模拟题:TestoftheJavaSkill(3)
JAVA模拟题:TestoftheJavaSkill(4)
JAVA基础:语言中链表和双向链表的实现(2)
全程追踪入侵JSP网站服务器
JavaSE6.0桌面API编程 (下)
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛