Java认证模拟题:onlyfortrainning
来源:优易学  2011-11-28 14:28:14   【优易学:中国教育考试门户网】   资料下载   IT书店

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



 
二.模拟题 

1.which statement about the garbage collection mechanism are true? 
a.garbage collection require additional program 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 explicit and immediately frees the memory used by java objects. 
d.the garbage collection mechanism can free the memory used by java object at expectable 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; 
system.out.println(a); 
9) } 
in the absence of compiler optimization, which is the earliest point the object a referred is definitely hand 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. 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 addxxxlistener method as many times as is needed, specifying as many different listeners as your design require. 

4.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 3b. doing it for l is 1c. doing it for l is 2 
d. doing it for l is 0e. doing it for l is –1f. finish 

5. 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. 1b. 2c. 3d. default 

6. give incompleted method: 
1) 
2){if(unsafe()){//do something…} 
3)else if(safe()){//do the other…} 
4)} 
the method unsafe() will throw 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 

7. 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<4b. x>;4c. x>;9d. none 

8. 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 1b. test 2c. test 3d. test 4 
9. which method you define as the starting point of new thread in a class from which new the thread can be execution? 
a. public void start()b. public void run()c. public void int() 
d. public static void main(string args[])e. public void runnable() 

10.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{} 

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

责任编辑:小草

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