- 1、本文档共8页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
J2SE 知识点巩固提高题
J2SE 知识点巩固提高题
Question 1
Click the Exhibit button.
1. public class A {
2.
3. static int counter = 0;
4.
5. public static int getInstanceCount() {
6. return counter;
7. }
8.
9. public A() {
10. ++counter;
11. }
12.
13. }
Given this code from Class B:
25.A a1 =new A();
26. A a2 =new A();
27. A a3 =new A();
28. System.out.printIn(A.getInstanceCount() );
What is the result?
A. Compilation of class A fails.
B. Line 28 prints the value 3 to System.out.
C. Line 28 prints the value 1 to System.out.
D. A runtime error occurs when line 25 executes.
E. Compilation fails because of an error on line 28.
Question 2
41. Given:
10. class One {
11. public One foo() { return this; }
12. }
13. class Two extends One {
14. public One foo() { return this; }
15. }
16. class Three extends Two {
17. // insert method here
18. }
Which two methods, inserted individually, correctly complete the
Three class? (Choose two.)
A. public void foo() { }
B. public int foo() { return 3; }
C. public Two foo() { return this; }
D. public Three foo() { return this; }
E. public Object foo() { return this; } 重写方法返回值不能比父类广。
Question 3
What will happen when you try compiling and running this code?
public class Test
{
static int i=10;
public static void main(String argv[])
{
Test t = new Test();
t.myMethod(t);
}
public void myMethod(Test t)
{
int i = 99;
function(t);
System.out.println(t.i);
}
public void function(Test t)
{
t.i = t.i * 2;
}
static{ i++;}
}
A. 编译错误, 静态方法不能调用实例方法.
B. An output of 99
C. An output of 198
D. An output of 22
E. An error at runtime
Question 4
Given:
1. public class Plant {
2. private String name;
3. public Plant(String name) { this.name = name; }
4. public String getName() { return name; }
5. }
1. public class Tree extends Plant {
2. public void growFruit() { }
3. public void dropLeaves() { }
4. }
Which is true? (choose two)
A. The code will compile without changes.
B. The code will compile if public Tree() { super(“fern”); } is added to the
Tree class.
C. The code will compile if pub
您可能关注的文档
最近下载
- 《控制图+第3部分:验收控制图GBT+17989.3-2020》详细解读.pdf
- 优秀教师评分细则(3篇).pdf VIP
- 《光电信息综合实验》课程教学大纲.doc VIP
- 《微积分》教案 1.4 两个重要极限.pdf VIP
- 《半导体封装技术》课程教学大纲(模板).docx VIP
- 思维训练与学习力提升-01-学习力的内涵与要素.pdf VIP
- UM-20200609-SIA-3000(COD)化学需氧量在线分析仪用户手册-1.10.pdf VIP
- UM-20200605-SIA-3000(NH3)氨氮水质在线分析仪用户手册-1.10.pdf VIP
- 水库大坝安全监测和管理特点研究.doc VIP
- 项目管理入门教程项目管理入门教程.ppt VIP
文档评论(0)