资源预览内容
第1页 / 共24页
第2页 / 共24页
第3页 / 共24页
第4页 / 共24页
第5页 / 共24页
第6页 / 共24页
第7页 / 共24页
第8页 / 共24页
第9页 / 共24页
第10页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1: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 2: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 3:Which statements about Java code security are not true? A.The bytecode verifier loads all classes needed for the execution of a program. B.Executing code is performed by the runtime interpreter. C.At runtime the bytecodes are loaded, checked and run in an interpreter. D.The class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources. 4:Select valid identifier of Java:A.%passwd B.3d_game C.$charge D.this 5:The following code is entire contents of a file called Example.java,causes precisely one error during compilation:class SubClass extends BaseClassclass BaseClass()String str;public BaseClass()System.out.println(“ok”);public BaseClass(String s)str=s;public class Examplepublic 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 6:Use the operator “” and “”. Which statement is true? A.1010 0000 0000 0000 0000 0000 0000 0000 4 give 0000 1010 0000 0000 0000 0000 0000 0000 B.1010 0000 0000 0000 0000 0000 0000 0000 4 give 1111 1010 0000 0000 0000 0000 0000 0000 C.1010 0000 0000 0000 0000 0000 0000 0000 4 give 0000 0000 0000 0000 0000 0000 0000 0000 D.1010 0000 0000 0000 0000 0000 0000 0000 4 give 1111 1010 0000 0000 0000 0000 0000 0000 7: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 = 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. 13: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; 简答题简答题16:说说你对面向切面编程(AOP)的理解。 开发人员在编写应用程序时,通常包含两种代码:一种是和业务系统有关系的代码,一种 是和业务系统关系不大的代码,例如日志,事务处理,权限处理等等。以前的程序中,这 两种代码是写在一起的。这样一来,程序中到处充满着相同或类似的代码,不利于维护。 而 Aop 的目标就是使这两种代码分离解耦,这样程序员就能专心于业务的处理,而且达到 维护和重用的目的。17:已知 abc+cba=1333,其中 a,b,c 均为一位数,编程求出满足条件的 a,b,c 所有组合。 public class ABCCBA1333 public static void main(String args) for(int a=0;a100) break; B.for (;); C.int k=1000; do +k; while(k=10000); D.int s=36; while (s);-s; 7:public class OuterClass private double d1 = 1.0; /insert code here You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?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; 8:关于垃圾收集的哪些叙述是对的。 A.程序开发者必须自己创建一个线程进行内存释放的工作。 B.垃圾收集将检查并释放不再使用的内存。 C.垃圾收集允许程序开发者明确指定并立即释放该内存。 D.垃圾收集能够在期望的时间释放被 java 对象使用的内存。 9:Give the following java class: public class Example static int x=new int15; 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. 10:设有变量说明语句 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.有语法错误 11:以下的 C 程序代码片段运行后 C 和 d 的值分别是多少 Int a =1,b =2; Int c,d; c =(a d =(a A.0,0 B.0,1 C.1,0 D.1,1 12: 给出下面的代码片断。下面的哪些陈述为错误的? 1) public void create() 2) Vector myVect; 3) myVect = new Vector(); 4) A.第二行的声明不会为变量 myVect 分配内存空间。 B.第二行语句创建一个 Vector 类对象。 C.第三行语句创建一个 Vector 类对象。 D.第三行语句为一个 Vector 类对象分配内存空间 13:Give the following code: public class Example public static void main(String args ) int l=0; do System.out.println(“Doing it for l is:”+l); while(-l0) System.out.println(“Finish”); Which well be output: A.Doing it for l is 3 B.Doing it for l is 1 C.Doing it for l is 2 D.Doing it for l is 0 14:Give the code fragment: if(x4) System.out.println(“Test 1”); else if (x9) System.out.println(“Test 2”); else System.out.println(“Test 3”); Which range of value x would produce of output “Test 2”? A.x4 C.x9 D.None 15:Which of the following statements are not legal? A.long l = 4990; B.int i =
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号