- 1、本文档共36页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
[IT认证]SCJP认证考试题库3
QUESTION 121
Given:
Which code, inserted at line 15, creates an instance of the Point class defined in Line?
A. Point p = new Point();
B. Line.Point p = new Line.point();
C. The Point class cannot be instatiated at line 15.
D. Line 1 = new Line() ; 1.Point p = new 1.Point();
Answer: ( B )
静态内部类创建方法 非静态内部类的构造:Line.Point p = new Line().new Point();
参考大纲:面向对象 — 内部静态类
QUESTION 122
Given:
Which statement is true?
A. The code will compile without changes.
B. The code will compile if public Tree() { Plant(); } is added to the Tree class.
C. The code will compile if public Plant() { Tree(); } is added to the Plant class.
D. The code will compile if public Plant() { this(fern); } is added to the Plant class.
E. The code will compile if public Plant() { Plant(fern); } is added to the Plant class.
Answer: ( D )
子类默认调用父类无参构造函数,而Plant没有无参构造函数,因此须显示调用有参构造函数
参考大纲:面向对象
QUESTION 123
Given:
Which two code fragments, inserted independently at line 12, will allow the class to compile? (Choose two.)
A. foreach( x ) System.out.print1n(z);
B. for( int z : x ) System.out.print1n(z);
C. while( x.hashNext() ) System.out.print1n( x.next() )
D. for( int i=0; i x.length; i++ ) System.out.println(x[i]);
Answer: ( B, D )
可变参数方法编译后变成数组参数方法,然后利用循环结构取出数组的值
参考大纲:流程控制和可变长度参数
QUESTION 124
Exhibit:
Which statement is true about the classes and interfaces in the exhibit?
A. Compilation will succeed for all classes and interfaces.
B. Compilation of class C will fail because of an error in line 2.
C. Compilation of class C will fail because of an error in line 6.
D. Compilation of class AImpl will fail because of an error in line 2.
Answer: ( C )
参考大纲:面向对象 — 复写
QUESTION 125
Place the lines in the correct order to complete the enum。
enum Element {
Answer: ( )
enum Element {
EARTH, WIND,
FIRE{
public String info(){return “Hot”;}
};
public String info(){return “element”;}
}
列举的内容之后要加上“;”
参考大纲:面向对象 — enum
QUESTION 126
Place the code elements in order so that th
文档评论(0)