Java程序员认证模拟题及详细分析(1)
来源:优易学  2010-1-15 9:40:09   【优易学:中国教育考试门户网】   资料下载   IT书店

 

  10. Which method you define as the starting point of new thread in a class from which new the thread can be excution?
  A. public void start()
  B. public void run()
  C. public void int()
  D. public static void main(String args[])
  E. public void runnable()

6-10答案:
  6。B.C
  在开关语句中,标号总是不被当做语句的一部分,标号的作用就是做为条件判断而已,一旦匹配成功,就执行其后的语句,一直遭遇break语句为止。(包括default语句在内)
  7。D、F
  IOException异常类是Exception的子类。根据多态性的定义,IOException对象也可以被认为是Exception类型。还要注意在方法声明中抛出异常应用关键字“throws”。
  8。D
  只有两种情况:大于4时输出“Test1”,小于等于4时输出“Test3”。
  9。A、C、D
  在正常情况下,打印Test1、Test3、Test4;在产生可捕获异常时打印Test2、Test3、Test4;在产生不可捕获异常时,打印Test3,然后终止程序。注意finally后面的语句总是被执行。
  10。B
  线程的执行是从方法“run( )”开始的,该方法是由系统调用的。程序员手工调用方法start(),使线程变为可运行状态。

  11.Given the following class definition:
  class A{
  protected int i;
  A(int i){
  this.i=i;
  }
  }
  which of the following would be a valid inner class for this class?
  Select all valid answers:
  A. class B{
  }
  B. class B extends A{
  }
  C. class B extends A{
  B(){System.out.println(“i=” i);}
  }
  D. class B{
  class A{}
  }
  E. class A{}

  12. Which modifier should be applied to a method for the lock of object this to be obtained prior to excution any of the method body?
  A. synchronized
  B. abstract
  C. final
  D. static
  E. public

  13. The following code is entire contents of a file called Example.java,causes precisely one error during compilation:
  1) class SubClass extends BaseClass{
  2) }
  3) class BaseClass(){
  4) String str;
  5) public BaseClass(){
  6) System.out.println(“ok”);}
  7) public BaseClass(String s){
  8) str=s;}}
  9) public class Example{
  10) public void method(){
  11) SubClass s=new SubClass(“hello”);
  12) BaseClass b=new BaseClass(“world”);
  13) }
  14) }

  Which line would be cause the error?
  A. 9 B. 10 C. 11 D.12

  14. Which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object?
  A. String [] a
  B. String a[]
  C. char a[][]
  D. String a[50]
  F. Object a[50]

  15. Give the following java source fragement:
  //point x
  public class Interesting{
  //do something
  }
  Which statement is correctly Java syntax at point x?
  A. import java.awt.*;
  B.package mypackage
  C. static int PI=3.14
  D. public class MyClass{//do other thing…} E. class MyClass{//do something…}

上一页  [1] [2] [3] [4] 下一页

责任编辑:cyth

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训