 
         
         
         
         
        
            已阅读5页,还剩3页未读,            继续免费阅读
        
        
                版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
            J2SE 知识点巩固提高题选择题解答方式: 1. 写出答案 2. 写出做出选择的理由 3. 简略书写相关知识点要点Question 1Click 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 241. 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 here18. Which two methods, inserted individually, correctly complete theThree 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 3What will happen when you try compiling and running this code?public class Teststatic 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 99C. An output of 198D. An output of 22E. An error at runtimeQuestion 4Given:1. public class Plant 2. private String name;3. public Plant(String 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 theTree class.C. The code will compile if public Plant() Tree(); is added to thePlant class.D. The code will compile if public Plant() this(”fern”); is added tothe Plant class.E. The code will compile if public Plant() super(”fern”); is added tothe Plant class.Question 5Given:11. public class Test 12. public static void main(String args) 13. int x =5;14. boolean b1 = true;15. boolean b2 = false;16.17.if(x=4) & !b2)18. System.out.print(”l “);19. System.out.print(”2 “);20. if (b2 = true) & b1)21. System.out.print(”3 “);22. 23. What is the result?A. 2B. 3C. 1 2D. 2 3E. 1 2 3F. Compilation fails.G. Au exceptional is thrown at runtime.Question 6Given:10. interface Foo 11. class Alpha implements Foo 12. class Beta extends Alpha 13. class Delta extends Beta 14. public static void main( String args) 15. Beta x = new Beta();16. / insert code here17. 18. Which code, inserted at line 16, will cause ajava.lang.ClassCastException?A. Alpha a = x;B. Foo f= (Delta)x;C. Foo f= (Alpha)x;D. Beta b = (Beta)(Alpha)x;Question 7Assume that country is set for each class.Given:10. public class Money 11. private String country, name;12. public String getCountry() return country; 13.and:24. class Yen extends Money 25. public String getCountry() return super.country; 26. 27.28. class Euro extends Money 29. public String getCountry(String timeZone) 30. return super.getCountry();31. 32. Which two are correct? (Choose two.)A. Yen returns correct values.B. Euro returns correct values.C. An exception is thrown at runtime.D. Yen and Euro both return correct values.E. Compilation fails because of an error at line 25.F. Compilation fails because of an error at line 30.Question 812. Given:13. public class Pass 14. public static void main(String args) 15. int x=5;16. Pass p = new Pass();17. p.doStuff(x);18. System.out.print(” main x = “+ x);19. 20.21. void doStuff(int x) 22. System.out.print(” doStuff x = “+ x+);23. 24. What is the result?A. Compilation fails.B. An exception is thrown at runtime.C. doStuffx = 6 main x = 6D. doStuffx = 5 main x = 5E. doStuffx = 5 main x = 6F. doStuffx = 6 main x = 5 Question 9Given:1. class TestA 2. public void start() System.out.println(”TestA”); 3. 4. public class TestB extends TestA 5. public void start() System.out.println(”TestB”); 6. public static void main(String args) 7. (TestA)new TestB().start();8. 9. What is the result?A. TestAB. TestBC. Compilation fails.D. An exception is thrown at runtime.Question 10What will happen when you attempt to compile and run this code?abstract class Baseabstract public void myfunc() ;public void another()System.out.println(Another method);public class Abs extends Basepublic static void main(String argv)Base b= new Abs(); /Ab. myfunc(); /Bpublic void myfunc()System.out.println(My Func);public void amethod()myfunc();1 choice1) The code will compile and run, printing out the words My Func2) The compiler will complain error at /A.3) The compiler will complain error at /B.4) The compiler will complain error at other position.Question 11What will be the output when the following code is compiled and run (Assuming written inside main)?String s1 = new String(amit);System.out.println(s1.replace(m,r);System.out.println(s1);String s3 = arit;String s4 = arit;String s2 = s1.replace(m,r);System.out.println(s2 = s3);System.out.println(s3 = s4);1 choiceA. aritamitfalsetrueB. aritarittruetrueC. amitamitfalsefalseD. aritarittruefalseQuestion 12Given:What will happen if you compile/run the following code?class MyClassint x;MyClass(int i)x = i;public static void main(String args)MyClass m1 = new MyClass(100);MyClass m2 = new MyClass(100);System.out.println(m1=m2);if(m1.equals(m2)System.out.println(Both are equal);elseSystem.out.println(Both are not equal);1 choiceA. Compilation error: equals() method was not defined.B. true Both are equalC. false Both are equal.D. true Both are not equal.E. false Both are not equalQuestion 131. public class test 2. public static void add3 (Integer i) 3. int val = Value ( );4. val += 3;5. i = new Integer (val);6. 7.8. public static void main (String args ) 9. Integer i = new Integer (0);10. add3 (i);11. system.out.printIn (Value ( );12. 13. )What is the result?A. Compilation will fail.B. The program prints “0”.C. The program prints “3”.D. Compilation will succeed but an exception will be thrown at line 3.Question 14Given:1. public class ConstOver 2. public ConstOver        
    温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业人力资源规划与管理
- 2025年兴平中考数学真题及答案
- 神经外科硬膜下血肿手术围术期管理规范
- 胆囊炎常见症状及护理护士技能
- 2026年二级建造师之二建公路工程实务考试题库500道带答案(黄金题型)
- 2026年县乡教师选调考试《教师职业道德》题库100道含答案【巩固】
- 2026年材料员之材料员基础知识考试题库300道【网校专用】
- 2025年镇里招人考试题目及答案
- 肝胆外科护理宣教
- 2026年一级注册建筑师之建筑物理与建筑设备考试题库300道含答案(培优a卷)
- 2025年入团考试试题库问答题部分及解析答案
- 管理咨询项目考核方案
- 2025管理学原理企业管理试题及答案
- 玉雕理论考试题库及答案
- 灵山县病死禽畜无害化处理项目环评报告
- 2025至2030年中国城市排水系统行业发展潜力分析及投资方向研究报告
- 院感紫外线消毒培训课件
- 肿瘤中心质控汇报
- 2025年特种设备监管b证考试试题及答案
- 污水过滤系统维修方案(3篇)
- 学堂在线 生活英语进阶 章节测试答案
 
            
评论
0/150
提交评论