免费预览已结束,剩余13页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
选择题 1: Whatwillbetheresultofexecutingthefollowingcode? /Filename;SuperclassX.java packagepackageX; publicclassSuperclassX protectedvoidsuperclassMethodX() intsuperclassVarX; /FilenameSubclassY.java 1.packagepackageX.packageY; 2. 3.publicclassSubclassYextendsSuperclassX 4. 5.SuperclassXobjX=newSubclassY(); 6.SubclassYobjY=newSubclassY(); 7.voidsubclassMethodY() 8. 9.objY.superclassMethodX(); 10.inti; 11.i=objY.superclassVarX; 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 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.Compilation error at line 9 C.Runtime exception at line 11 D.None of these 2: ThefollowingcodeisentirecontentsofafilecalledExample.java,causespreciselyoneerrorduringcompilation: classSubClassextendsBaseClass classBaseClass() Stringstr; publicBaseClass() System.out.println(“ok”); publicBaseClass(Strings) str=s; publicclassExample publicvoidmethod() SubClasss=newSubClass(“hello”); BaseClassb=newBaseClass(“world”); Whichlinewouldbecausetheerror?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 BaseClass(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: Whatwillbeprintedwhenyouexecutethefollowingcode? classX Yb=newY(); X() System.out.print(X); classY Y() System.out.print(Y); publicclassZextendsX Yy=newY(); Z() System.out.print(Z); publicstaticvoidmain(Stringargs) newZ(); 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); public static void main(String args) new Z(); Choices:A.Z B.YZ C.XYZ D.YXYZ 5: Giventhefollowingclassdefinition: classA protectedinti; A(inti) this.i=i; whichofthefollowingwouldbeavalidinnerclassforthisclass? Selectvalidanswer:Given the following class definition:class Aprotected int i;A(int i)this.i=i;which of the following would be a valid inner 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: 下述程序代码中有语法错误的行是()。 inti,ia10,ib10;/*第一行*/for(i=0;i=9;i+)/*第2行*/iai=0;/*第3行*/ib=ia;/*第4行*/下述程序代码中有语法错误的行是( )。int i,ia10,ib10; /*第一行*/for (i=0;i=9;i+) /*第2行*/ iai=0; /*第3行*/ib=ia; /*第4行*/A.第1行 B.第2行 C.第3行 D.第4行 7: Givethisclassoutline: classExample privateintx; /restofclassbody AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofExample.java?Give this class outline:class Exampleprivate int x;/rest of class bodyAssuming that x invoked by the code java Example, which statement can 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.-2 C.-1 D.8 9: publicclassOuterClass privatedoubled1=1.0; /insertcodehere Youneedtoinsertaninnerclassdeclarationatline3.Whichtwoinnerclassdeclarationsare 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() return 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 compile without any error? A.StringBuffer sb1 = abcd; B.Boolean b = new Boolean(abcd); C.C: byte b = 255; D.float fl = 1.2; 12: publicclassX publicObjectm() Objecto=newFloat(3.14F);/line3 Objectoa=newObject1;/line4 oa0=o;/line5 o=null;/line6 returnoa0;/line7 WhenistheFloatobject,createdinline3,eligibleforgarbagecollection?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 collection?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: Givethefollowingjavasourcefragement: /pointx publicclassInteresting /dosomething WhichstatementiscorrectlyJavasyntaxatpointx?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 other 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: Whatwillhappenwhenyouattempttocompileandrunthefollowingcode? intOutput=10; booleanb1=false; if(b1=true)&(Output+=10)=20) System.out.println(Weareequal+Output); else System.out.println(Notequal!+Output); 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 System.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! 10. 16: Whatwillbetheresultofexecutingthefollowingcode? booleana=true; booleanb=false; booleanc=true; if(a=true) if(b=true) if(c=true)System.out.println(Somethingsaretrueinthisworld); elseSystem.out.println(Nothingistrueinthisworld!); elseif(a&(b=c)System.out.println(Itstooconfusingtotellwhatistrueandwhatisfalse); elseSystem.out.println(Heythiswontcompile); Choices:What will be the result of executing the following code? boolean a = true; boolean b = false; 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(Its too confusing to tell what is true and what is false); else System.out.println(Hey this wont compile); Choices:A.The code wont compile B.Some things are true in this world will be printed C.Hey this wont compile will be printed D.None of these 17: 给出下面的代码片断。下面的哪些陈述为错误的? 1)publicvoidcreate() 2)VectormyVect; 3)myVect=newVector(); 4)给出下面的代码片断。下面的哪些陈述为错误的?1) public void create() 2) Vector myVect;3) myVect = new Vector();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.Component don?t allow multiple listeners to be add. D.none 19: SelectvalididentifierofJava:Select valid identifier of Java:A.%passwd B.3d_game C.$charge D.this 20: Whichisthemostappropriatecodesnippetthatcanbeinsertedatline18inthefollowingcode? (Assumethatthecodeiscompiledandrunwithassertionsenabled) 1.importjava.util.*; 2. 3.publicclassAssertTest 4. 5.privateHashMapcctld; 6. 7.publicAssertTest() 8. 9.cctld=newHashMap(); 10.cctld.put(in,India); 11.cctld.put(uk,UnitedKingdom); 12.cctld.put(au,Australia); 13./morecode. 14. 15./othermethods. 16.publicStringgetCountry(StringcountryCode) 17. 18./Whatshouldbeinsertedhere? 19.Stringcountry=(String)cctld.get(countryCode); 20.returncountry; 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 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. public 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 country code data is available; D.assert cctld : No country code data is available; 21: Whatistheresultwhenyoucompileandrunthefollowingcode? publicclassTest publicvoidmethod() for(inti=0;i3;i+) System.out.print(i); System.out.print(i); Choices:What is the result when you compile and run the following code? public class Test public void method()for(int i = 0; i 3; i+) System.out.print(i); Sys
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 广州市花都区人民法院2025年下半年公开招聘政府雇员工作易考易错模拟试题(共500题)试卷后附参考答案
- 医疗服务外包协议书
- 校园高利贷合同范本
- 广东惠州博罗县中小企业管理局招聘政府购买服务岗位工作人员易考易错模拟试题(共500题)试卷后附参考答案
- 公司提供宿舍协议书
- 企业消防联动协议书
- 山东日照市住房公积金管理中心2025年下半年招考工作人员易考易错模拟试题(共500题)试卷后附参考答案
- 宝鸡石油钢管限责任公司博士后科研工作站招考易考易错模拟试题(共500题)试卷后附参考答案
- 不锈钢安装合同范本
- 天津华能杨柳青热电限责任公司招聘易考易错模拟试题(共500题)试卷后附参考答案
- 2025年竹缠绕复合管市场调研报告
- 《经济形势分析》课件
- 水利电工考试试题及答案
- 律师合伙协议书样本
- 天车培训课件下载
- 三一挖机保养手册
- 高中生环境保护课题研究性学习报告
- 山东会考历年会考题及答案
- 外研版高一到高三单词表
- 科学组织幼儿园生活活动
- GB/T 14646-2025轿车翻新轮胎
评论
0/150
提交评论