分类信息
各地考试

当前位置:首页 » Java认证 » 历年真题 » 正文

SCJP认证历年经典考题(5)


时间:2013-10-22 来源:Java认证考试网 浏览次数:207  【华夏培训网:中国教育培训第一门户

QuestionNo21 Given: 8.intindex=1; 9.intfoo=newint; 10.intbar=foo[index]; 11.intbaz=bar+index; Whatistheresult? A.Bazhas

Question No 21 
Given: 
8. int index = 1; 
9. int foo = new int ; 
10.int bar = foo [index]; 
11.int baz = bar + index; 
What is the result? 
A. Baz has the value of 0 
B. Baz has the value of 1 
C. Baz has the value of 2 
D. An exception is thrown. 
E. The code will not compile. 
Answer: B 

Question No 22 
Given: 
1. public class foo { 
2. public static void main (Stringargs) { 
3. String s; 
4. system.out.printIn (“s=” + s); 
5. } 
6. } 
What is the result? 
A. The code compiles and “s=” is printed. 
B. The code compiles and “s=null” is printed. 
C. The code does not compile because string s is not initialized. 
D. The code does not compile because string s cannot be referenced. 
E. The code compiles, but a NullPointerException is thrown when toString is called. 
Answer: C 

Question No 23 
Which will declare a method that forces a subclass to implement it? 
A. Public double methoda(); 
B. Static void methoda (double d1) {} 
C. Public native double methoda(); 
D. Abstract public void methoda(); 
E. Protected void methoda (double d1){} 
Answer: D 

Question No 24 
You want subclasses in any package to have access to members of a superclass. Which is the most 
restrictive access modifier that will accomplish this objective? 
A. Public 
B. Private 
C. Protected 
D. Transient 
E. No access modifier is qualified 
Answer: C 






       Java认证

推荐图文

热门点击排行

©2015 hxpx.com All Rights Reserved 滇ICP备13002816号-1
华夏培训网唯一网址www.hxpx.com