动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   程序开发 → 阅读文章

 Test of the Java Skill(3)

作者来源: 
阅读 数 157 人次 , 2006-4-27 17:46:00 


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

   Question 21:
   Why might you define a method as native?
   A. To get to access hardware that Java does not know about

   B. To define a new data type such as an unsigned integer

   C. To write optimized code for performance in a language such as C/C++

   D. To overcome the limitation of the private scope of a method

   Question 22:
   What will happen when you attempt to compile and run the following code with the command line “hello there”?

   public class Arg{
   String[] MyArg;
   public static void main(String argv[]){
   MyArg = argv;
   }
   public void amethod(){
   System.out.println(argv[1]);
   }
   }

   A. Compile time error

   B. Compilation and output of “hello”

   C. Compilation and output of “there”

   D. None of the above

   Question 23:
   What will be printed out if this code is run with the following command line?
   java myprog good morning

   public class myporg{ 
   public static void main(String argv[]){
   System.out.println(argv[2]);
   }
   }

   A. myprog

   B. good

   C. morning

   D. Exception raised: “java.lang.ArrayIndexOutOfBoundsException: 2”

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

   public class Hope{
   public static void main(String argv[]){
   Hope h = new Hope();
   }

   protected Hope(){
   for (int i=0; i<10; i++){
   System.out.println(i);
   }
   }
   }

   A. Compilation error: Constructors cannot be declared protected

   B. Run time error: Constructors cannot be declared protected

   C. Compilation and running with output 0 to 10

   D. Compilation and running with output 0 to 9(CN-JAVA)

  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:Test of the Java Skill(4)
· 下一篇:Test of the Java Skill(2)
· 解析UML的要点与应用
· 基于Java 2平台的引用类使用指南(1)
· AJAX技术之如何处理书签和翻页按扭
· 最新Sun授权ASEC-Java培训中心一览表
· 构架Linux环境下Java开发环境(2)


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077