网站大量收购闲置独家精品文档,联系QQ:2885784924

J2SE 知识点巩固提高题.doc

  1. 1、本文档共8页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
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

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档