The application will crash.
The code on line 29 will be executed.
The code on line 5 of class A will execute.
The exception will be propagated back to line 27.
The code on line 5 of class B will execute.
第1题:
A.Line 26 prints "a" to System.out.
B.Line 26 prints "b" to System.out.
C.An exception is thrown at line 26 at runtime.
D.Compilation of class A will fail due to an error in line 6.
第2题:
Class TestException 1. public class TestException extends Exception { 2. } Class a: 1. public class a { 2. 3. public String sayHello(String name) throws TestException { 4. 5. if(name == null) { 6. throw new TestException(); 7. } 8. 9. return “Hello “+ name; 10. } 11. 12. } A programmer wants to use this code in an application: 45. A a=new A(); 46. System.out.println(a.sayHello(”John”)); Which two are true?()
第3题:
1.class TestSuper { 22.TestSuper(int i) { } 3. } 4.class TestSub extends TestSuper{ } 5.class TestAll { 6.public static void main (String [] args) { 7.new TestSub(); 8.} 9.} Which is true?()
第4题:
You are working on a debug build of an application.You need to find the line of code that caused an exception to be thrown. Which property of the Exception class should you use to achieve this goal?()
第5题:
1. public class A { 2. public void method1() { 3. B b=new B(); 4. b.method2(); 5. // more code here 6. } 7. } 1. public class B { 2. public void method2() { 3.C c=new C(); 4. c.method3(); 5. // more code here 6. } 7. } 1. public class C { 2. public void method3() { 3. // more code here 4. } 5. } Given: 25. try { 26. A a=new A(); 27. a.method1(); 28. } catch (Exception e) { 29. System.out.print(”an error occurred”); 30. } Which two are true if a NullPointerException is thrown on line 3 of class C?()
第6题:
You work as an application developer at Certkiller .com. Certkiller .com has instructed you to create a class named MetricFormula. This class will be used to compare MetricUnit and EnglishUnit objects.The MetricFormula is currently defined as follows (Line numbers are used for reference purposes only): 1. public class MetricFormula2. { 3. 4. } You need to ensure that the MetricFormula class can be used to compare the required objects. What should you do? ()
第7题:
Compilation will succeed for all classes and interfaces.
Compilation of class C will fail because of an error in line 2.
Compilation of class C will fail because of an error in line 6.
Compilation of class AImpl will fail because of an error in line 2.
第8题:
Compilation of class A fails.
Line 28 prints the value 3 to System.out.
Line 28 prints the value 1 to System.out.
A runtime error occurs when line 25 executes.
Compilation fails because of an error on line 28.
第9题:
Line 26 prints "a" to System.out.
Line 26 prints "b" to System.out.
An exception is thrown at line 26 at runtime.
Compilation of class A will fail due to an error in line 6.
第10题:
The declaration on line 2 does not allocate memory space for the variable myVect.
The declaration on line 2 allocates memory space for a reference to a Vector object.
The statement on line 2 creates an object of class Vector.
The statement on line 3 creates an object of class Vector.
The statement on line 3 allocates memory space for an object of class Vector.
第11题:
Line 33 must be called within a try block.
The exception thrown by method 1 in class A is not required to be caught.
The method declared on line 31 must be declared to throw a runtime exception.
On line 5 of class A,the call to method 2 of class B does not need to be placed in a try catch block.
第12题:
The application will crash.
The code on line 29 will be executed.
The code on line 5 of class A will execute.
The code on line 5 of class B will execute.
The exception will be propagated back to line 27.
第13题:
A.The application will crash.
B.The code on line 29 will be executed.
C.The code on line 5 of class A will execute.
D.The code on line 5 of class B will execute.
E.The exception will be propagated back to line 27.
第14题:
1. public class a { 2. public void method1() { 3. try { 4. B b=new b(); 5. b.method2(); 6. // more code here 7. } catch (TestException te) { 8. throw new RuntimeException(te); 9. } 10. } 11. } 1. public class b { 2. public void method2() throws TestException { 3. // more code here 4. } 5. } 1. public class TestException extends Exception { 2. } Given: 31. public void method() { 32. A a=new a(); 33. a.method1(); 34. } Which is true if a TestException is thrown on line 3 of class b?()
第15题:
1. public class A { 2. void A() { 3. System.out.println(“Class A”); 4. } 5. public static void main(String[] args) { 6. new A(); 7. } 8. } What is the result?()
第16题:
10. class Line { 11. public static class Point { } 12. } 13. 14. class Triangle { 15. // insert code here 16. } Which code, inserted at line 15, creates an instance of the Point class defined in Line?()
第17题:
Given the following code fragment: public void create() { Vector myVect; myVect = new Vector(); } Which of the following statements are true?()
第18题:
Add the following code on line 1: : IComparable {
Add the following code on line 1: : IComparer {
Add the following code on line 3: public int Compare (object x, object y) {// implementation code }
Add the following code on line 3: public int CompareTo (object obj) {// implementation code }
第19题:
int foo() { /* more code here */ }
void foo() { /* more code here */ }
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
第20题:
Compilation of class A fails.
Line 28 prints the value 3 to System.out.
Line 28 prints the value 1 to System.out.
Compilation fails because of an error on line 28.
A runtime error occurs when line 25 executes.
第21题:
Line 33 must be called within a try block.
The exception thrown by method1 in class a is not required to be caught.
The method declared on line 31 must be declared to throw a RuntimeException.
On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.
第22题:
The application will crash.
The code on line 29 will be executed.
The code on line 5 of class A will execute.
The code on line 5 of class B will execute.
The exception will be propagated back to line 27.
第23题:
The instance gets garbage collected.
The code on line 33 throws an exception.
The code on line 35 throws an exception.
The code on line 31 throws an exception.
The code on line 33 executes successfully.
第24题:
Class A
Compilation fails.
An exception is thrown at line 2.
An exception is thrown at line 6.
The code executes with no output.