北京派克兰帝_第1页
北京派克兰帝_第2页
北京派克兰帝_第3页
北京派克兰帝_第4页
北京派克兰帝_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

选择题 1: Which of the following statements are true? A.The automatic garbage collection of the JVM prevents programs from ever running out of memory B.A program can suggest that garbage collection be performed and force it C.Garbage collection is platform independent D.An object becomes eligible for garbage collection when all references denoting it are set to null. 2: 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. 3: 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 100) break; B.for (;); C.int k=1000; do +k; while(k=10000); D.int s=36; while (s);-s; 9: 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 10:下面关于变量及其范围的陈述哪些是错的。 A.实例变量是类的成员变量。 B.实例变量用关键字static声明。 C.在方法中定义的局部变量在该方法被执行时创建 D.局部变量在使用前必须被初始化。 11: Inthefollowingcode,whichistheearlieststatement,wheretheobjectoriginallyheldine,maybegarbagecollected: 1.publicclassTest 2.publicstaticvoidmain(Stringargs) 3.Employeee=newEmployee(Bob,48); 4.e.calculatePay(); 5.System.out.println(e.printDetails(); 6.e=null; 7.e=newEmployee(Denise,36); 8.e.calculatePay(); 9.System.out.println(e.printDetails(); 10. 11. OnlyOne:In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected: 1.public class Test 2. public static void main (String args ) 3. Employee e = new Employee(Bob, 48); 4. e.calculatePay(); 5. System.out.println(e.printDetails(); 6. e = null; 7. e = new Employee(Denise, 36); 8. e.calculatePay(); 9. System.out.println(e.printDetails(); 10. 11.Only One: A.Line 10 B.Line 11 C.Line 7 D.Line 8 12: Givethefollowingjavaclass: publicclassExample publicstaticvoidmain(Stringargs) staticintx=newint15; System.out.println(x5); Whichstatementiscorrected?Give the following java class:public class Examplepublic static void main(String args)static int x = new int15;System.out.println(x5);Which statement is corrected?A.When compile, some error will occur. B.When run, some error will occur. C.Output is zero. D.Output is null. 13:Which statement about the garbage collection mechanism are true? A.Garbage collection require additional programe code in cases where multiple threads are running. B.The programmer can indicate that a reference through a local variable is no longer of interest. C.The programmer has a mechanism that explicity and immediately frees the memory used by Java objects. D.The garbage collection mechanism can free the memory used by Java Object at explection time. 14:Which of the following answer is correct to express the value 8 in octal number? A.010 B.0x10 C.08 D.0x8 15:关于垃圾收集的哪些叙述是对的。 A.程序开发者必须自己创建一个线程进行内存释放的工作。 B.垃圾收集将检查并释放不再使用的内存。 C.垃圾收集允许程序开发者明确指定并立即释放该内存。 D.垃圾收集能够在期望的时间释放被java对象使用的内存。 16: 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 17: 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 18: Consider the class hierarchy shown below: - class FourWheeler implements DrivingUtilities class Car extends FourWheeler class Truck extends FourWheeler class Bus extends FourWheeler class Crane extends FourWheeler - Consider the following code below: 1.DrivingUtilities du; 2.FourWheeler fw; 3.Truck myTruck = new Truck(); 4.du = (DrivingUtilities)myTruck; 5.fw = new Crane(); 6.fw = du; Which of the statements below are true? Choices: A.Line 4 will not compile because an interface cannot refer to an object. B.The code will compile and run. C.The code will not compile without an explicit cast at line 6, because going down the hierarchy without casting is not allowed. D.The code will compile if we put an explicit cast at line 6 but will throw an exception at runtime. 19: Whatwillhappenwhenyouattempttocompileandrunthefollowingcode? publicclassStatic static intx=5; staticintx,y; publicstaticvoidmain(Stringargs) x-; myMethod(); System.out.println(x+y+x); publicstaticvoidmyMethod() y=x+x; Choices:What will happen when you attempt to compile and run the following code? public class Staticstaticint x = 5; static int x,y;public static void main(String args) x-; myMethod(); System.out.println(x + y + +x); public static void myMethod()y = x+ + +x; Choices:A.prints : 2 B.prints : 3 C.prints : 7 D.prints : 8 20:设有变量说明语句int a=1,b=0; 则执行以下程序段的输出结果为( )。 switch (a) case 1: switch (b) case 0:printf(*0*);break; case 1:printf(*1*);break; case 2:printf(*2*);break; printf(n); A.*0* B.*0*2* C.*0*1*2* D.有语法错误 简答题 21:不允许使用系统时间,写出一个随机数生成函数。 22:说说你对面向切面编程(AOP)的理解。 23: 找出其中的错误,并说明原因。 interfacePlayable voidplay(); interfaceBounceable voidplay(); interfaceRollableextendsPlayable,Bounceable Ballball=newBall(PingPang); classBallimplemen

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论