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

 Test of the Java Skill(2)

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


   Question 9:
   What code placed after the comment:
     // Start For loop
   would populate the elements of the array ia[] with values of the variables i ?

   public class Lin{
   public static void main(String argv[]){
   Lin l = new Lin();
   l.amethod();
   }

   public void amethod(){
   int ia[] = new int[4];
   // Start For loop
   {
   ia[i] = i;
   System.out.println(ia[i]);
   }
   }
   }

   A. for(int i=0; i

   B. for (int i=0; i

   C. for(int i=0; i<4; i++)

   D. for(int i=0; i

   Question 10:
   Consider the following code:
   Integer s = new Integer(9);
   Integer t = new Integer(9);
   Long u = new Long(9);
   Which test would return true?
  A. (s==u)

   B. (s==t)

   C. (s.equals(t))

   D. (s.equals(9))

   E. (s.equals(new Integer(9))

   Question 11:
   Which of the following is successfully create an instance of the Vector class and add an element?

   A. Vector v = new Vector(99);
   v[1]=99;

   B. Vector v = new Vector();
   v.addElement(99);

   C. Vector v = new Vector();
   v.add(99);

   D. Vector v = new Vector(100);
   v.addElement(“99”);

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

   class Base{
   private void amethod(int iBase){
   System.out.println(“Base.amethod”);
   }
   }

   class Over extends Base{
   public static void main(String argv[]){
   Over o = new Over();
   int iBase=0;
   o.amethod(iBase);
   }

   public void amethod(int iOver){
   System.out.println(“Over.amethod”);
   }
   }

   A. Compile time error complaining that Base.amethod is private

   B. Runtime error complaining that Base.amethod is private

   C. Output of Base.amethod

   D. Output of Over.amethod

   Question 13:
   What will happen if you try to compile and run the following code?

   public class MyClass
   public static void main(String arguments[]){
   amethod(arguments);
   }

   public void amethod(String[] arguments)
   System.out.println(arguments);
   System.out.println(arguments[1]);
   }
   }

   A. Error can't make static reference to void amethod

   B. Error method main not correct

   C. Error array must include parameter

   D. Error amethod must be declared with String

   Question 14:
   If you wanted to find out where the position of the letter v (i.e. return 2) in the string s containing “Java”, which of the following could you use?

   A. mid(2,s);

   B. charAt(2);

   C. s.indexOf(‘v');

   D. indexOf(s,'v');

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

   public class Bground extends Thread{

   public static void main(String argv[]){
   Bground b = new Bground();
   b.run();
   }
   public void start(){
   for (int i=0;i<10;i++){
   System.out.println(“Value of i=” + i);
   }
   }
   }
   A. A compile time error indicating that no run method is defined for the Thread class

   B. A run time error indicating that no run method is defined for the Thread class

   C. Clean compile and at run time the values 0 to 9 are printed out

   D. Clean compile but no output at runtime

   Question 16:
   What will happen when you compile the following code?

   public class MyClass{
   static int i;

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

   A. Error Variable i may out have been initialized

   B. null

   C. 1

   D. 0(CN-JAVA)

  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:Test of the Java Skill(3)
· 下一篇:Test of the Java Skill(1)
· PB中一个类Word打印对话框的实现
· 将32位代码向64位平台移植的注意事项
· 我有一个梦
· Windows XP系统默认设置带来的7个安全问题
· PB6.5在窗口刚打开动态调整Tab


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