欢迎光临
我们一直在努力

java程序员认证模拟题及详细分析(1)_java认证

建站超值云服务器,限时71元/月

一.说明:(真实考试)
1.考试形式:网络计算机
2.考题形式:多选,单选,简答
3.题量:60
4.考试时间:120分钟

二.模拟题

1.Which statement about the garbage collection mechanism are true?
A. Garbage collection require additional programe code in cases where multiple threads are running.
B. The programmer can indicate that a reference through a local variable is no longer of interest.
C. The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.
D. The garbage collection mechanism can free the memory used by Java Object at explection time.
E. The garbage collection system never reclaims memory from objects while are still accessible to running user threads.

2. Give the following method:
1) public void method( ){
2) String a,b;
3) a=new String(“hello world”);
4) b=new String(“game over”);
5) System.out.println(a+b+”ok”);
6) a=null;
7) a=b;
8) System.out.println(a);
9) }
In the absence of compiler optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection.
A. before line 3
B.before line 5
C. before line 6
D.before line 7
E. Before line 9

3. In the class java.awt.AWTEvent,which is the parent class upon which jdk1.1 awt events are based there is a method called getID which phrase accurately describes the return value of this method?
A. It is a reference to the object directly affected by the cause of the event.
B. It is an indication of the nature of the cause of the event.
C. It is an indication of the position of the mouse when it caused the event.
D. In the case of a mouse click, it is an indication of the text under the mouse at the time of the event.
E. It tells the state of certain keys on the keybord at the time of the event.
F. It is an indication of the time at which the event occurred.

4. Which statement about listener is true?
A. Most component allow multiple listeners to be added.
B. If multiple listener be add to a single component, the event only affected one listener.
C. Component don?t allow multiple listeners to be add.
D. The listener mechanism allows you to call an addXxxxListener method as many times as is needed, specifying as many different listeners as your design require.

5.Give the following code:
public class Example{
public static void main(String args[] ){
int l=0;
do{
System.out.println(“Doing it for l is:”+l);
}while(–l>0)
System.out.println(“Finish”);
}
}
Which well be output:
A. Doing it for l is 3
B. Doing it for l is 1
C. Doing it for l is 2
D. Doing it for l is 0
E. Doing it for l is ?C1
F. Finish

见1-5题答案
答案及详细分析:

   1。B、E
JAVA的垃圾回收机制是通过一个后台系统级线程对内存分配情况进行跟踪实现的,对程序员来说是透明的,程序员没有任何方式使无用内存显示的、立即的被释放。而且它是在程序运行期间发生的。
答案B告诉我们程序员可以使一个本地变量失去任何意义,例如给本地变量赋值为“null”;答案E告诉我们在程序运行期间不可能完全释放内存。
2。D
第6行将null赋值给a以后,a以前保存的引用所指向的内存空间就失去了作用,它可能被释放。所以对象a可能最早被垃圾回收是在第7行以前,故选择D选项。
3。B
请查阅JAVA类库。getID方法的返回值是“event type”。在认证考试中,总会有类似的书本以外的知识,这只能靠多实践来增长知识了。
4。A、D
控件可以同时使用多个“addXxxxListener”方法加入多个监听器。并且当多个监听器加入到同一控件中时,事件可以响应多个监听器,响应是没有固定顺序的。
5。D、F
本题主要考察考生对流程控制的掌握情况。这是当型循环,条件为真执行,条件为假则退出。循环体至少执行一次,故会输出D。循环体以外的语句总会被执行,故输出F。

6. Give the code fragment:
1) switch(x){
2) case 1:System.out.println(“Test 1”);break;
3) case 2:
4) case 3:System.out.println(“Test 2”);break;
5) default:System.out.println(“end”);
6) }
which value of x would cause “Test 2” to the output:
A. 1
B. 2
C. 3
D. default

7. Give incompleted method:
1)
2) { if(unsafe()){//do something…}
3) else if(safe()){//do the other…}
4) }
The method unsafe() well throe an IOException, which completes the method of declaration when added at line one?
A. public IOException methodName()
B. public void methodName()
C. public void methodName() throw IOException
D. public void methodName() throws IOException
E. public void methodName() throws Exception

8. Give the code fragment:
if(x>4){
System.out.println(“Test 1”);}
else if (x>9){
System.out.println(“Test 2”);}
else {
System.out.println(“Test 3”);}
Which range of value x would produce of output “Test 2”?
A. x<4
B. x>4
C. x>9
D. None

9. Give the following method:
public void example(){
try{
unsafe();
System.out.println(“Test1”);
}catch(SafeException e){System.out.println(“Test 2”);
}finally{System.out.println(“Test 3”);}
System.out.println(“Test 4”);
Which will display if method unsafe () run normally?
A. Test 1
B. Test 2
C. Test 3
D. Test 4

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…}

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) 用“==”进行比较时,符号两边的数据类型必须一致(可相互转换的基本类型除外),否则编译出错。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » java程序员认证模拟题及详细分析(1)_java认证
分享到: 更多 (0)