




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
选择题 1: 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 2: Whatwillbetheresultofexecutingthefollowingcode? publicstaticvoidmain(Stringargs) chardigit=a; for(inti=0;i10;i+) switch(digit) casex: intj=0; System.out.println(j); default: intj=100; System.out.println(j); inti=j; System.out.println(i); Choices:What will be the result of executing the following code? public static void main(String args) char digit = a; for (int i = 0; i =0:methodB(); System.out.println(i); publicvoidmethodB() System.out.println(Thevaluemustnotbenegative); publicstaticvoidmain(Stringargs) AssertTesttest=newAssertTest(); test.methodA(-10); What will happen when you attempt to compile and run the following code?(Assume that the code is compiled and run with assertions enabled.)public class AssertTestpublic void methodA(int i)assert i = 0 : methodB();System.out.println(i);public void methodB() System.out.println(The value must not be negative);public static void main(String args)AssertTest test = new AssertTest();test.methodA(-10); A.it will print -10 B.it will result in AssertionError showing the message-“the value must not be negative”. C.the code will not compile. D.None of these. 5: Whatresultsfromattemptingtocompileandrunthefollowingcode? publicclassTernary publicstaticvoidmain(Stringargs) inta=5; System.out.println(Valueis-+(a5)?9.9:9); Choices:What results from attempting to compile and run the following code? public class Ternarypublic static void main(String args)int a = 5;System.out.println(Value is - + (a 5) ? 9.9 : 9); Choices:A.prints: Value is - 9 B.Compilation error C. prints: Value is - 5 D.None of these 6:Which is the main() method return of a application? A.String B.byte C.char D.void 7: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 8: 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. 9:在软件生命周期中,下列哪个说法是不准确的? A.软件生命周期分为计划、开发和运行三个阶段 B.在计划阶段要进行问题焉醛和需求分析 C.在开发后期要进行编写代码和软件测试 D.在运行阶段主要是进行软件维护 10: Whatistheresultwhenyoucompileandrunthefollowingcode? publicclassThrowsDemo staticvoidthrowMethod() System.out.println(InsidethrowMethod.); thrownewIllegalAccessException(demo); publicstaticvoidmain(Stringargs) try throwMethod(); catch(IllegalAccessExceptione) System.out.println(Caught+e); Choices:What is the result when you compile and run the following code? public class ThrowsDemo static void throwMethod() System.out.println(Inside throwMethod.); throw new IllegalAccessException(demo); public static void main(String args) try throwMethod(); catch (IllegalAccessException e) System.out.println(Caught + e); Choices:A.Compilation error B.Runtime error C.Compile successfully, nothing is printed. D.Inside throwMethod. followed by caught:java.lang.IllegalAccessExcption: demo 11: 给出下面的代码片断。下面的哪些陈述为错误的? 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类对象分配内存空间 12: 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 13:假定a和b为int型变量,则执行下述语句组后,b的值为 a=1; b=10; do b-=a; a+; while (b-0); A.9 B.-2 C.-1 D.8 14:软件生命周期的瀑布模型把软件项目分为3个阶段、8个子阶段,以下哪一个是正常的开发顺序? A.计划阶段、开发阶段、运行阶段 B.设计阶段、开发阶段、编码阶段 C.设计阶段、编码阶段、维护阶段 D.计划阶段、编码阶段、测试阶段 15: 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 16: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; 简答题 17:试为下列关键字设计哈希表,要求所设计的表在查找成功时的平均查找长度不超过2.0。并请验证你造的哈希表的实际平均查找长度时否满足要求。(CHA,CAI,LAN,WEN,LONG,ZHAO,WU,LIU,CHEN,LI,WANG,CAO,YUN,CHANG,YANG) 18:有一篇英文文章(也就是说每个单词之间由空格分隔),请找出“csdn”着个单词出现的次数,要求效率最高,并写出算法的时间级。 19: 找出以下程序错误。 ClassTest privateStringpar1; privateStringpar2; Test() p
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 齐鲁大联考数学试卷
- 施工方案管理培训内容(3篇)
- 户外丛林寻宝活动方案策划(3篇)
- 配套主体结构施工方案(3篇)
- 新闻编辑考试题库及答案
- 公安考试题库做法及答案
- 安徽省六安市金寨县2024-2025学年高三上学期期末考试历史题目及答案
- 心理学应用题目及答案
- 心肺复苏考试题目及答案
- 农村社区物业管理服务合同
- 知识题库-人社劳动知识竞赛测试题及答案(十五)
- 《民宿管家》课件-民宿管家之预订接待
- 部编小学语文单元作业设计四年级上册第三单元 3
- 《信号完整性测试》课件2
- 火电厂检修培训课件
- 学校文印室外包服务 投标方案(技术方案)
- 电力公司招聘考试题库及答案详解
- DB6101T141-2018猕猴桃水肥一体化施肥技术规程
- 2024年度医院心内介入科医务人员述职报告课件
- 制造业绿色生产与环境可持续发展
- 安徽省高速公路施工标准化指南
评论
0/150
提交评论