QUESTION NO 132 Which four types of objects can be thrown using the throw statement? (Choose Four) A. Error B. Event C. Object D. Exception E. Throwable F. RuntimeException
Answer: A, D, E, F
QUESTION NO 133 Given: 1. public class ForBar { 2. public static void main(String []args) { 3. int i = 0, j = 5; 4. tp: for (;;) { 5. i ++; 6. for(;;) 7. if(i > --j) break tp; 8. } 9. system.out.printIn(“i = ” + i + “, j = “+ j); 10. } 11. } What is the result? A. The program runs and prints “i=1, j=0” B. The program runs and prints “i=1, j=4” C. The program runs and prints “i=3, j=4” D. The program runs and prints “i=3, j=0” E. An error at line 4 causes compilation to fail. F. An error at line 7 causes compilation to fail. Answer: A
QUESTION NO 134 Which two can directly cause a thread to stop executing? (Choose Two) A. Exiting from a synchronized block. B. Calling the wait method on an object. C. Calling the notify method on an object. D. Calling the notifyAll method on an object. E. Calling the setPriority method on a thread object.
Answer: B, E
QUESTION NO 135 Given: 1. public class Foo implements Runnable ( 2. public void run (Thread t) { 3. system.out.printIn(“Running.”); 4. } 5. public static void main (String[] args) { 6. new thread (new Foo()).start(); 7. ) 8. ) What is the result? A. An exception is thrown. B. The program exists without printing anything. C. An error at line 1 causes compilation to fail. D. An error at line 6 causes the compilation to fail. E. “Running” is printed and the program exits.
Answer: C
QUESTION NO 136 Which constructs a DataOutputStream? A. New dataInputStream(“in.txt”); B. New dataInputStream(new file(“in.txt”)); C. New dataInputStream(new writer(“in.txt”)); D. New dataInputStream(new FileWriter(“in.txt”)); E. New dataInputStream(new InputStream(“in.txt”)); F. New dataInputStream(new FileInputStream(“in.txt”));
Answer: F
QUESTION NO 137 Which can be used to decode charS for output? A. Java.io.InputStream. B. Java.io.EncodedReader. C. Java.io.InputStreamReader. D. Java.io.InputStreamWriter. E. Java.io.BufferedInputStream. Answer: C
QUESTION NO 138 Given: 1. public class Test { 2. public static void main (String [] args) { 3. string foo = “blue”; 4. string bar = foo; 5. foo = “green”; 6. System.out.printIn(bar); 7. } 8. } What is the result? A. An exception is thrown. B. The code will not compile. C. The program prints “null” D. The program prints “blue” E. The program prints “green” Answer: D
QUESTION NO 139 Which code determines the int value foo closest to a double value bar? A. Int foo = (int) Math.max(bar); B. Int foo = (int) Math.min(bar); C. Int foo = (int) Math.abs(bar); D. Int foo = (int) Math.ceil(bar); E. Int foo = (int) Math.floor(bar); F. Int foo = (int) Math.round(bar);
Answer: F
QUESTION NO 140 Which two demonstrate encapsulation of data? (Choose Two) A. Member data have no access modifiers. B. Member data can be modified directly. C. The access modifier for methods is protected. D. The access modifier to member data is private. E. Methods provide for access and modification of data.
Answer: D, E
QUESTION NO 141 Exhibit: 1. class A { 2. public String toString () { 3. return “4”; 4. } 5. } 6. class B extends A { 7. 8. public String toString () { 8. return super.toString() + “3”; 9. } 10. } 11. public class Test { 12. public static void main(String[]args) { 13. System.out.printIn(new B()); 14. } 15. } What is the result? A. Compilation succeeds and 4 is printed. B. Compilation succeeds and 43 is printed. C. An error on line 9 causes compilation to fail. D. An error on line 14 causes compilation to fail. E. Compilation succeeds but an exception is thrown at line 9.
Answer: B
QUESTION NO 142 Which two statements are true? (Choose Two) A. An anonymous inner class can be declared inside of a method B. An anonymous inner class constructor can take arguments in some situation. C. An anonymous inner class that is a direct subclass that is a direct subclass of Object can implement multiple interfaces. D. Even if a class Super does not implement any interfaces, it is still possible to define an anonymous inner class that is an immediate subclass of Super that implements a single interface. E. Event if a class Super does not implement any interfaces, it is still possible to define an anonymous inner class that is an immediate subclass of Super that implements multiple interfaces.
Answer: A, B
QUESTION NO 143 Given: 1. public class MethodOver { 2. private int x, y; 3. private float z; 4. public void setVar(int a, int b, float c){ 5. x = a; 6. y = b; 7. z = c; 8. } 9. } Which two overload the setVar method? (Choose Two) A. void setVar (int a, int b, float c){ x = a; y = b; z = c; } B. public void setVar(int a, float c, int b) { setVar(a, b, c); } C. public void setVar(int a, float c, int b) { this(a, b, c); } D. public void setVar(int a, float b){ x = a; z = b; } E. public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }
Answer: B, D
QUESTION NO 144 Which statements about static inner classes are true? (Choose Two) A. A static inner class requires a static initializer. B. A static inner class requires an instance of the enclosing class. C. A static inner class has no reference to an instance of the enclosing class. D. A static inner class has access to the non-static members of the outer class. E. Static members of a static inner class can be referenced using the class name of the static inner class.
Answer: C, E
QUESTION NO 145 Given: 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; 9. 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).
Answer: C
QUESTION NO 146 Which two interfaces provide the capability to store objects using a key-value pair? (Choose Two) A. Java.util.Map. B. Java.util.Set. C. Java.util.List. D. Java.util.StoredSet. E. Java.util.StoredMap. F. Java.util.Collection.
Answer: A, E
QUESTION NO 147 Which interface does java.util.Hashable implement? A. Java.util.Map. B. Java.util.List. C. Java.util.Hashable. D. Java.util.Collection.
Answer: A
1140

被折叠的 条评论
为什么被折叠?



