版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、选择题 1: What will be the result of executing the following code? / Filename; SuperclassX.java package packageX; public class SuperclassX
2、0; protected void superclassMethodX() int superclassVarX; / Filename SubclassY.
3、java 1.package packageX.packageY; 2. 3.public class SubclassY extends SuperclassX 4. 5.SuperclassX objX = new SubclassY();
4、 6.SubclassY objY = new SubclassY(); 7.void subclassMethodY() 8. 9.objY.superclassMethodX(); 10.int i; 11.i = objY.superclassVarX
5、; 12. 13. Choices: What will be the result of executing the following code? / Filename; SuperclassX.javapackage packageX; public class SuperclassXprotected void superclassMethodX()int superclassVarX; / Filename
6、SubclassY.java1.package packageX.packageY;2.3.public class SubclassY extends SuperclassX4.5.SuperclassX objX = new SubclassY();6.SubclassY objY = new SubclassY();7.void subclassMethodY()8.9.objY.superclassMethodX();10.int i;11.i = objY.superclassVarX;12.13. Choices:A.Compilation error at line 5 B.Co
7、mpilation error at line 9 C.Runtime exception at line 11 D.None of these 2: The following code is entire contents of a file called Example.java,causes precisely one error during compilation: class SubCl
8、ass extends BaseClass class BaseClass() String str; public BaseClass() System.out.println(“ok”); public BaseClass(String s) str=s; &
9、#160; public class Example public void method() SubClass s=new SubClass(“hello”); BaseClass b=new BaseClass(“world”); Which line
10、would be cause the error? The following code is entire contents of a file called Example.java,causes precisely one error during compilation: class SubClass extends BaseClass class BaseClass() String str; public BaseClass() System.out.println(“ok”); public BaseCla
11、ss(String s) str=s; public class Example public void method() SubClass s=new SubClass(“hello”); BaseClass b=new BaseClass(“world”); Which line would be cause the error? A.9 B.10 C.11 D.12 3:鉴于Java的特点,它最适合的计算环境是 A.并行计算环境 B.分布式计算环境 C.高强度计算环境 D.开放式计算环境 4: What will be printed when
12、160;you execute the following code? class X Y b = new Y(); X() System.out.print("X");
13、160; class Y Y() System.out.print("Y");
14、 public class Z extends X Y y = new Y(); Z() System.out.print("Z&qu
15、ot;); public static void main(String args) new Z();
16、; Choices: What will be printed when you execute the following code? class X Y b = new Y(); X() System.out.print("X"); class Y Y() System.out.print("Y"); public class Z extends X Y y = new Y(); Z() System.out.print("Z&quo
17、t;); public static void main(String args) new Z(); Choices:A.Z B.YZ C.XYZ D.YXYZ 5: Given the following class definition: class A protected int i; A(int i) this.i=i; which
18、60;of the following would be a valid inner class for this class? Select valid answer: Given the following class definition:class Aprotected int i;A(int i)this.i=i;which of the following would be a valid inn
19、er class for this class?Select valid answer: A.class B B.class B extends A C.class B extends A B()System.out.println(“i=”+i); D.class B class A 6: 下述程序代码中有语法错误的行是( )。 int i,ia10,ib10; /*第一行*/ for (i=0;i<=9;i+)
20、60; /*第2行*/ iai=0; /*第3行*/ ib=ia; /*第4行*/ 下述程序代码中有语法错误的行是( )。int i,ia10,ib10; /*第一行*/for (i=0;i<=9;i+) /*第2行*/ iai=0; /*第3行*/ib=ia; /*第
21、4行*/A.第1行 B.第2行 C.第3行 D.第4行 7: Give this class outline: class Example private int x; /rest of class body Assuming that x invoked by the code java Example,
22、 which statement can made x be directly accessible in main() method of Example.java? Give this class outline:class Exampleprivate int x;/rest of class bodyAssuming that x invoked by the code java Example, which statement can
23、 made x be directly accessible in main() method of Example.java?A.Change private int x to public int x B.change private int x to static int x C.Change private int x to protected int x D.change private int x to final int x 8:假定a和b为int型变量,则执行下述语句组后,b的值为 a=1; b=10; do b-=a; a+; while (b-<0); A.9 B.-
24、2 C.-1 D.8 9: public class OuterClass private double d1 = 1.0; /insert code here You need to insert an inner class declaration at line 3. Which t
25、wo inner class declarations are valid? public class OuterClass private double d1 = 1.0;/insert code hereYou need to insert an inner class declaration at line 3. Which two inner class declarations arevalid?A.class InnerOne public static double methoda() retu
26、rn d1; B.public class InnerOne static double methoda() return d1; C.private class InnerOne double methoda() return d1; D.static class InnerOne protected double methoda() return d1; 10:Which are not Java keywords? A.TRUE B.const C.super D.void 11:In the following pieces of code, which one will compil
27、e without any error? A.StringBuffer sb1 = "abcd" B.Boolean b = new Boolean("abcd"); C.C: byte b = 255; D.float fl = 1.2; 12: public class X public Object m()
28、Object o = new Float(3.14F);/line 3 Object oa = new Object1;/line 4 oa0 = o;/line 5 &
29、#160; o=null;/line 6 return oa0;/line 7 When is the Float object, created
30、in line 3,eligible for garbage collection? public class X public Object m() Object o = new Float(3.14F);/line 3 Object oa = new Object1;/line 4 oa0 = o;/line 5 o=null;/line 6 return oa0;/line 7 When is the Float object, created in line 3,eligible for garbage colle
31、ction?A.just after line 5. B.just after line 6 C.just after line 7(that is,as the method returns) D.never in this method 13: Give the following java source fragement: /point x public class Interesting /do something
32、0; Which statement is correctly Java syntax at point x? Give the following java source fragement:/point xpublic class Interesting/do somethingWhich statement is correctly Java syntax at point x? A.public class MyClass/do othe
33、r thing B.static int PI=3.14 C.class MyClass/do something D.none 14:Which of the following statements are not legal? A.long l = 4990; B.int i = 4L; C.double d = 34.4; D.double t = 0.9F. 15: What will happen when you attempt to compile and run the
34、0;following code? int Output = 10; boolean b1 = false; if(b1 = true) && (Output += 10) = 20)
35、60; System.out.println("We are equal " + Output); else System.out.println("Not equal! " + O
36、utput); Choices: What will happen when you attempt to compile and run the following code? int Output = 10;boolean b1 = false; if(b1 = true) && (Output += 10) = 20) System.out.println("We are equal " + Output); else S
37、ystem.out.println("Not equal! " + Output); Choices:A.Compilation error, attempting to perform binary comparison on logical data type B.Compilation and output of "We are equal 10". C.Compilation and output of "Not equal! 20". D.Compilation and output of "Not equal!
38、10". 16: What will be the result of executing the following code? boolean a = true; boolean b = false; boolean c = true; if
39、0;(a = true) if (b = true) if (c = true) System.out.println("Some things are true in this world"); else
40、0;System.out.println("Nothing is true in this world!"); else if (a && (b = c) System.out.println("It's too confusing to tell what is true and
41、160;what is false"); else System.out.println("Hey this won't compile"); Choices: What will be the result of executing the following code? boolean a = true; boolean b = false;
42、 boolean c = true; if (a = true) if (b = true) if (c = true) System.out.println("Some things are true in this world"); else System.out.println("Nothing is true in this world!"); else if (a && (b = c) System.out.println("It's too confusing to tell what is true and
43、 what is false"); else System.out.println("Hey this won't compile"); Choices:A.The code won't compile B."Some things are true in this world" will be printed C."Hey this won't compile" will be printed D.None of these 17: 给出下面的代码片断。下面的哪些陈述为错误的?
44、0;1) public void create() 2) Vector myVect; 3) myVect = new Vector(); 4) 给出下面的代码片断。下面的哪些陈述为错误的?1) public void create() 2) Vector myVect;3) myVect = new Vector()
45、;4) A.第二行的声明不会为变量myVect分配内存空间。 B.第二行语句创建一个Vector类对象。 C.第三行语句创建一个Vector类对象。 D.第三行语句为一个Vector类对象分配内存空间 18:Which statement about listener is true? A.Most component allow multiple listeners to be added. B.If multiple listener be add to a single component, the event only affected one listener. C.Componen
46、t don?t allow multiple listeners to be add. D.none 19: Select valid identifier of Java: Select valid identifier of Java:A.%passwd B.3d_game C.$charge D.this 20: Which is the most appropriate code snippet that can be ins
47、erted at line 18 in the following code? (Assume that the code is compiled and run with assertions enabled) 1. import java.util.*;
48、60;2. 3. public class AssertTest 4. 5. private HashMap cctld; 6. 7
49、. public AssertTest() 8. 9. cctld = new HashMap(); 10.
50、 cctld.put("in", "India"); 11. cctld.put("uk", "United Kingdom"); 12.
51、0; cctld.put("au", "Australia"); 13. / more code. 14. 15. / other
52、 methods . 16. public String getCountry(String countryCode) 17. 18. / What
53、 should be inserted here? 19. String country = (String)cctld.get(countryCode); 20. return country; &
54、#160; 21. 22. Which is the most appropriate code snippet that can be inserted at line 18 in the following code?(Assume that the code is compiled and run with assertions enabled)1. import java.util.*;2. 3. public class
55、AssertTest4. 5. private HashMap cctld;6. 7. public AssertTest()8. 9. cctld = new HashMap();10. cctld.put("in", "India");11. cctld.put("uk", "United Kingdom");12. cctld.put("au", "Australia");13. / more code. 14. 15. / other methods . 16. pu
56、blic String getCountry(String countryCode)17. 18. / What should be inserted here?19. String country = (String)cctld.get(countryCode);20. return country;21. 22. A.assert countryCode != null; B.assert countryCode != null : "Country code can not be null" ; C.assert cctld != null : "No co
57、untry code data is available" D.assert cctld : "No country code data is available" 21: What is the result when you compile and run the following code? public class Test public void method() for(int i = 0;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年武汉市东西湖区社区工作者招聘笔试参考题库及答案详解
- 2026年贵港市覃塘区网格员招聘笔试参考题库及答案详解
- 企业员工工作焦虑对职场排斥感知的放大研究报告
- 企业员工工作不安全感对职场排斥行为的触发机制研究报告
- 2026年河北省唐山市事业编单位人员招聘考试备考题库及答案详解
- 2026年莆田市秀屿区网格员招聘笔试参考试题及答案详解
- 2026年呼伦贝尔市海拉尔区网格员招聘笔试参考题库及答案详解
- 2026年湖北省武汉市事业编单位人员招聘笔试参考题库及答案详解
- 2026年廊坊市安次区事业编单位人员招聘考试备考试题及答案详解
- 2026年铜陵市郊区社区工作者招聘笔试模拟试题及答案详解
- 2026湖南衡阳市衡东县卫健系统招聘专业技术人员46人模拟试卷完整附答案详解
- 2026-2030国内铁路电气设备行业市场发展分析及竞争格局与投资机会研究报告
- 2026-2030中国建筑信息模型(BIM)行业发展状况与前景趋势研究报告
- 2026年学校会计高频面试题包含详细解答
- 2026四川成都农业科技中心第二批招聘17人备考题库及1套完整答案详解
- 2026年秋人教部编版三年级语文上册教案全册
- 仓库货物收发验收管理规范
- 后勤管理工作不足对照检查材料范文
- 多病共存患者安全管理
- (2026年)检验检测机构资质认定“一单一库”的学习与解读(2026年实施)课件
- 2026年新教材人教PEP版(2024)四年级下册英语期末测试卷(含答案)
评论
0/150
提交评论