|
选择题 1: 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: 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: 1. public class X { 2. public object m () { 3. object o = new float (3.14F); 4. object [] oa = new object [1]; 5. oa[0]= o; 6. o = null; 7. oa[0] = null; 8.return o; 9. } 10.} When is the float object created in line 3, eligible for garbage collection? 1. public class X { 2. public object m () { 3. object o = new float (3.14F); 4. object [] oa = new object [1]; 5. oa[0]= o; 6. o = null; 7. oa[0] = null; 8.return o; 9. } 10.} 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 D.Just after line 8(that is, as the method returns) 3: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. 4:Which declares for native method in a java class corrected? A.public native void method(){} B.public native void method(); C.public native method(); D.public void native method(); 5:Which are not Java keywords? A.TRUE B.const C.super D.void 6: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 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? 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:public class Parent { int change() {…} } class Child extends Parent { } Which methods can be added into class Child? A.public int change(){} B.abstract int chang(){} C.private int change(){} D.none 9: What will happen when you attempt to compile and run the following code? class Base (责任编辑:职场达人) |


