杭州翰天网络科技_第1页
杭州翰天网络科技_第2页
杭州翰天网络科技_第3页
杭州翰天网络科技_第4页
杭州翰天网络科技_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

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

文档简介

1、选择题 1:关于垃圾收集的哪些叙述是对的。 A.程序开发者必须自己创建一个线程进行内存释放的工作。 B.垃圾收集将检查并释放不再使用的内存。 C.垃圾收集允许程序开发者明确指定并立即释放该内存。 D.垃圾收集能够在期望的时间释放被java对象使用的内存。 2: 1. String s=”Example String”;Which operation is not legal?  String s=”Example String”;Which operation is not legal?A.int i=s.leng

2、th(); B.s3=”x”; C.String short_s=s.trim(); D.String t=”root”+s; 3:What is written to the standard output given the following statement:System.out.println(4|7); Select the right answer: A.4 B.5 C.6 D.7 4:Which declares for native method in a java class corrected? A.public native void method() B.publi

3、c native void method(); C.public native method(); D.public void native method(); 5: 1. What happens when you try to compile and run the following program?   2. class Mystery   3. String s;   4. public 

4、;static void main(String args)   5. Mystery m=new Mystery();   6. m.go();   7.   8. void Mystery()   9. s=”constructor”;   10.   11. void go()   12. System.out.println(s);   1

5、3.   14.   What happens when you try to compile and run the following program?class MysteryString s;public static void main(String args)Mystery m=new Mystery();m.go();void Mystery()s=”constructor”;void go()System.out.println(s);A.this code compliles but throws an exception at run

6、time B.this code runs but nothing appears in the standard output C.this code runs and “constructor” in the standard output D.this code runs and writes ”null” in the standard output 6:public class Parent int change() class Child extends Parent Which methods can be added into class Child? A.public int

7、 change() B.abstract int chang() C.private int change() D.none 7: 1. What will happen when you attempt to compile and run the following code?    2.   3. public class Static   4.   5. &#

8、160; 6.   7. static  8.   9.   10.   11. int x = 5;   12.   13.     14.   15. static int x,y;   16.   17. public static void main(String

9、0;args)   18.   19.   20.   21.        x-;   22.   23.        myMethod();   24.   25.        System.out.println(x&#

10、160;+ y + +x);   26.   27.     28.   29. public static void myMethod()   30.   31.   32.   33. y = x+ + +x;   34.   35.   36.  

11、60;37.     38.   39. 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 myMeth

12、od()y = x+ + +x; Choices:A.prints : 2 B.prints : 3 C.prints : 7 D.prints : 8 8:A class design requires that a particular member variable must be accessible for direct access by any subclasses of this class. but otherwise not by classes which are not members of the same package. What should be done t

13、o achieve this? A.The variable should be marked public B.The variable should be marked private C.The variable should be marked protected D.The variable should have no special access modifier 9: 1. Give the following code:   2. public class Example   3. pu

14、blic static void main(String args )   4. int l=0;   5. do   6. System.out.println(“Doing it for l is:”+l);   7. while(-l>0)   8. System.out.println(“Finish”);   9.   10.  &

15、#160;11. Which well be output:   Give the following code:public class Examplepublic static void main(String args )int l=0;doSystem.out.println(“Doing it for l is:”+l);while(-l>0)System.out.println(“Finish”);Which well be output: A.Doing it for l is 3 B.Doing it for l

16、 is 1 C.Doing it for l is 2 D.Doing it for l is 0 10:假定a和b为int型变量,则执行下述语句组后,b的值为 a=1; b=10; do b-=a; a+; while (b-<0); A.9 B.-2 C.-1 D.8 11:Which fragments are not correct in Java source file? A.package testpackage; public class Test/do something. B.import java.io.*; package testpackage; public c

17、lass Test/ do something. C.import java.io.*; class Person/ do something. public class Test/ do something. D.import java.io.*; import java.awt.*; public class Test/ do something. 12: 1. Give this class outline:   2. class Example   3. private int x; &

18、#160; 4. /rest of class body   5.   6. Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of&#

19、160;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 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 sta

20、tic int x C.Change private int x to protected int x D.change private int x to final int x 13: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; 14:Which of

21、the following answer is correct to express the value 8 in octal number? A.010 B.0x10 C.08 D.0x8 15: 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

22、 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. 16: 1. Give the following java class:   2. public class Example   3. static int 

23、x=new int15;   4. public static void main(String args)   5. System.out.println(x5);   6.   7.   8. Which statement is corrected?  Give the following java class:public class Examplestatic int x=new int

24、15;public static void main(String args)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. 17: 1. What will happen when you attempt to compile and

25、0;run the following code?   2.   3. (Assume that the code is compiled and run with assertions enabled.)   4.   5. public class AssertTest   6.   7. public void&

26、#160;methodA(int i)   8.   9. assert i >= 0 : methodB();   10.   11. System.out.println(i);   12.   13.   14.   15. public void methodB()     16.   

27、;17. System.out.println("The value must not be negative");   18.   19.   20.   21. public static void main(String args)   22.   23. AssertTest test = new AssertTest(

28、);   24.   25. test.methodA(-10);    26.   27.   28.   29.   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 AssertTestpu

29、blic 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 AssertionE

30、rror showing the message-“the value must not be negative”. C.the code will not compile. D.None of these. 18:Which is the main() method return of a application? A.String B.byte C.char D.void 19:设有变量说明语句int a=1,b=0; 则执行以下程序段的输出结果为( )。 switch (a) case 1: switch (b) case 0:printf("*0*");break;

31、 case 1:printf("*1*");break; case 2:printf("*2*");break; printf("n"); A.*0* B.*0*2* C.*0*1*2* D.有语法错误 20: 1. What is the result when you compile and run the following code?    2.   3. public class Test   4.   5.     6.   7. public void method()   8.   9.   10.   11. for(int i = 0; i < 3; i+)   12.  &#

温馨提示

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

评论

0/150

提交评论