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

 

11-15答案:
 11。A
  此题考查内部类及关键字“super”的用法。内部类不能与外部类同名。另外,当B继承A时,A中的构造函数是带参数的,B中缺省构造函数的函数体为空;而JAVA编译器会为空构造函数体自动添加语句“super();”调用父类构造函数,更进一步是调用父类的参数为空的构造函数。而父类中没有参数为空的构造函数。
  12。A
  此关键字可以在两个线程同时试图访问某一数据时避免数据毁损。
  13。C
  当一个类中未显式定义构造函数时,缺省的构造函数是以类名为函数名,参数为空,函数体为空。虽然父类中的某一构造函数有字符串参数s,但是子类继承父类时并不继承构造函数,所以它只能使用缺省构造函数。故在第11行出错。
  14。A、B
  注意,题中问的是如何正确声明一个一维数组,并非实例化或者初始化数组
  15。A、E
  X处可以是一个输入,包的定义,类的定义。由于常量或变量的声明只能在类中或方法中,故不能选择C;由于在一个文件中只能有一个public类,故不能选择D。

  16. Give this class outline:
  class Example{
  private int x;
  //rest of class body…
  }
  Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?
  A. Change private int x to public int x
  B. change private int x to static int x
  C. Change private int x to protected int x
  D. change private int x to final int x

  17. the piece of preliminary analsis work describes a class that will be used frequently in many unrelated parts of a project
“The polygon object is a drawable, A polygon has vertex information stored in a vector, a color, length and width.”
Which Data type would be used?
  A. Vector
  B. int
  C. String
  D. Color
  E. Date

  18. A class design requires that a member variable should be accessible only by same package, which modifer word should be used?
  A. protected
  B. public
  C. no modifer
  D. private

  19.Which declares for native method in a java class corrected?
  A. public native void method(){}
  B. public native void method();
  C. public native method();
  D. public void method(){native;}
  E. public void native method();

  20. Which modifer should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object?

16-20答安:
  16。B
  静态方法除了自己的参数外只能直接访问静态成员。访问非静态成员,必须先实例化本类的一个实例,再用实例名点取。
  17。A、B、D
  polygon的顶点信息存放在Vector类型的对象内部,color定义为Color,length和width定义为int。
  注意,这是考试中常见的题型。
  18。C
  此题考点是高级访问控制。请考生查阅高级访问控制说明表格。
  19。B
  native关键字指明是对本地方法的调用,在JAVA中是只能访问但不能写的方法,它的位置在访问权限修饰语的后面及返回值的前面。
  20。final
  定义常量的方法是在变量定义前加final关键字。

  21. Which is the main() method return of a application?
  A. String
  B. byte
  C. char
  D. void

  22. Which is corrected argument of main() method of application?
  A. String args
  B. String ar[]
  C. Char args[][]
  D. StringBuffer arg[]

  23. “The Employee object is a person, An Employee has appointment store in a    vector, a hire date and a number of dependent”
  short answer: use shortest statement declare a class of Employee.

  24. Give the following class defination inseparate source files:
  public class Example{
  public Example(){//do something}
  protected Example(int i){//do something}
  protected void method(){//do something}
  }
  public class Hello extends Example{//member method and member variable}
  Which methods are corrected added to the class Hello?
  A. public void Example(){}
  B. public void method(){}
  C. protected void method(){}
  D. private void method(){}

  25. Float s=new Float(0.9F);
  Float t=new Float(0.9F);
  Double u=new Double(0.9);
  Which expression?s result is true?
  A. s==t
  B. s.equals(t)
  C. s==u
  D. t.equals(u)
21-15答案:
  21。D
  main()方法没有返回值,所以必须用void修饰。main()方法的返回值不能任意修改。
  22。B
  main()方法的参数是字符串数组,参数名可以任意定义。
  23。public class Employee extends Person
  这也是真实考试中常见的一种题型。要注意题目叙述中“is a”表示 “extends”的含义。
  24。A、B、C
  考察的知识点是方法覆盖,其中要注意的是方法覆盖时,子类方法的访问权限不能小于父类方法的访问权限。另外,选项A并不是父类构造函数,它是子类中的新方法。
  25。A、B
  考察“==”及方法“equals()”的用法。注意以下几点区别:
  1) 引用类型比较引用;基本类型比较值。
  2) equals()方法只能比较引用类型,“==”可比较引用及基本类型。
  3) 当用equals()方法进行比较时,对类File、String、Date及封装类(Wrapper Class)来说,是比较类型及内容。
  4) 用“==”进行比较时,符号两边的数据类型必须一致(可相互转换的基本类型除外),否则编译出错。

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

责任编辑:cyth

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