niusouti.com

多选题Click the Exhibit button. Given: Which two statements are true if a NullPointerException is thrown on line 3 of class C? ()AThe application will crash.BThe code on line 29 will be executed.CThe code on line 5 of class A will execute.DThe code on line

题目
多选题
Click the Exhibit button. Given: Which two statements are true if a NullPointerException is thrown on line 3 of class C? ()
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.


相似考题
参考答案和解析
正确答案: A,B
解析: 暂无解析
更多“多选题Click the Exhibit button. Given: Which two statements are true if a NullPointerException is thrown on line 3 of class C? ()AThe application will crash.BThe code on line 29 will be executed.CThe code on line 5 of class A will execute.DThe code on line”相关问题
  • 第1题:

    Click the Exhibit button. Given:Which statement is true if a TestException is thrown on line 3 of class B? ()

    A.Line 33 must be called within a try block.

    B.The exception thrown by method1 in class A is not required to be caught.

    C.The method declared on line 31 must be declared to throw a RuntimeException.

    D.On line 5 of class A, the call to method2 of class B does not need to be placed in a try/catch block.


    参考答案:B

  • 第2题:

    Click the Exhibit button. Given:Which two statements are true if a NullPointerException is thrown on line 3 of class C? ()

    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.


    参考答案:B, E

  • 第3题:

    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?()

    • A、Data
    • B、Message
    • C、Stack Trace
    • D、Source

    正确答案:C

  • 第4题:

    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?()

    • 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.

    正确答案:B,E

  • 第5题:

    Given the following code:     1) class Parent {     2) private String name;     3) public Parent(){}     4) }  5) public class Child extends Parent {     6) private String department;  7) public Child() {}  8) public String getValue(){ return name; }     9) public static void main(String arg[]) {     10) Parent p = new Parent();     11) }  12) }  Which line will cause error?()   

    • A、 line 3
    • B、 line 6
    • C、 line 7
    • D、 line 8
    • E、 line 10

    正确答案:D

  • 第6题:

    Given:   10. class One {   11. void foo() { }   12. }   13. class Two extends One {   14. //insert method here   15. }   Which three methods, inserted individually at line 14, will correctly complete class Two?()

    • A、 public void foo() { /* more code here */ }
    • B、 private void foo() { /* more code here */ }
    • C、 protected void foo() { /* more code here */ }
    • D、 int foo() { /* more code here */ }  
    • E、 void foo() { /* more code here */ }

    正确答案:A,C,E

  • 第7题:

    多选题
    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? ()
    A

    Add the following code on line 1: : IComparable {

    B

    Add the following code on line 1: : IComparer {

    C

    Add the following code on line 3: public int Compare (object x, object y) {// implementation code }

    D

    Add the following code on line 3: public int CompareTo (object obj) {// implementation code }


    正确答案: A,D
    解析: 暂无解析

  • 第8题:

    单选题
    Click the Exhibit button. Which statement is true about the classes and interfaces in the exhibit?()
    A

    Compilation will succeed for all classes and interfaces.

    B

    Compilation of class C will fail because of an error in line 2.

    C

    Compilation of class C will fail because of an error in line 6.

    D

    Compilation of class AImpl will fail because of an error in line 2.


    正确答案: B
    解析: 暂无解析

  • 第9题:

    单选题
    Click the Exhibit button. Given this code from Class B: 25.A a1 = new A(); 26.A a2 = new A(); 27.A a3 = new A(); 28.System.out.println(A.getInstanceCount()); What is the result?()
    A

    Compilation of class A fails.

    B

    Line 28 prints the value 3 to System.out.

    C

    Line 28 prints the value 1 to System.out.

    D

    A runtime error occurs when line 25 executes.

    E

    Compilation fails because of an error on line 28.


    正确答案: D
    解析: 暂无解析

  • 第10题:

    单选题
    Click the Exhibit button. What is the result?()
    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.


    正确答案: C
    解析: 暂无解析

  • 第11题:

    多选题
    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?()
    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.


    正确答案: D,C
    解析: 暂无解析

  • 第12题:

    多选题
    class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()
    A

    int foo() { /* more code here */ }

    B

    void foo() { /* more code here */ }

    C

    public void foo() { /* more code here */ }

    D

    private void foo() { /* more code here */ }

    E

    protected void foo() { /* more code here */ }


    正确答案: C,D
    解析: 暂无解析

  • 第13题:

    Click the Exhibit button.Given:What is the result?()

    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.


    参考答案:A

  • 第14题:

    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?()  

    • A、 Compilation fails.
    • B、 The code runs without exception.
    • C、 An exception is thrown at line 7.
    • D、 An exception is thrown at line 2.

    正确答案:A

  • 第15题:

    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?() 

    • A、 Point p = new Point();
    • B、 Line.Point p = new Line.Point();
    • C、 The Point class cannot be instatiated at line 15.
    • D、 Line 1 = new Line() ; 1.Point p = new 1.Point();

    正确答案:B

  • 第16题:

    Given the following code fragment:     public void create() {     Vector myVect;     myVect = new Vector();      }  Which of the following statements are true?() 

    • A、 The declaration on line 2 does not allocate memory space for the variable myVect.
    • B、 The declaration on line 2 allocates memory space for a reference to a Vector object.
    • C、 The statement on line 2 creates an object of class Vector.
    • D、 The statement on line 3 creates an object of class Vector.
    • E、 The statement on line 3 allocates memory space for an object of class Vector.

    正确答案:A,D,E

  • 第17题:

    10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?() 

    • A、 Point p = Line.getPoint();
    • B、 Line.Point p = Line.getPoint();
    • C、 Point p = (new Line()).getPoint();
    • D、 Line.Point p = (new Line()).getPoint();

    正确答案:D

  • 第18题:

    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? ()

    • A、 Add the following code on line 1: : IComparable {
    • B、 Add the following code on line 1: : IComparer {
    • C、 Add the following code on line 3: public int Compare (object x, object y) {// implementation code }
    • D、 Add the following code on line 3: public int CompareTo (object obj) {// implementation code }

    正确答案:B,C

  • 第19题:

    多选题
    Given:   10. class One {   11. void foo() { }   12. }   13. class Two extends One {   14. //insert method here   15. }   Which three methods, inserted individually at line 14, will correctly complete class Two?()
    A

    public void foo() { /* more code here */ }

    B

    private void foo() { /* more code here */ }

    C

    protected void foo() { /* more code here */ }

    D

    int foo() { /* more code here */ }

    E

    void foo() { /* more code here */ }


    正确答案: A,C,E
    解析: 暂无解析

  • 第20题:

    多选题
    Given: Which three methods, inserted individually at line 14, will correctly complete class Two?()
    A

    int foo() { /* more code here */ }

    B

    void foo() { /* more code here */ }

    C

    public void foo() { /* more code here */ }

    D

    private void foo() { /* more code here */ }

    E

    protected void foo() { /* more code here */ }


    正确答案: D,B
    解析: 暂无解析

  • 第21题:

    单选题
    Click the Exhibit button.   Given this code from Class B:   25. A a1 = new A();   26. A a2 = new A();   27. A a3 = new A();   28. System.out.println(A.getInstanceCount());   What is the result?()
    A

     Compilation of class A fails.

    B

     Line 28 prints the value 3 to System.out.

    C

     Line 28 prints the value 1 to System.out.

    D

     Compilation fails because of an error on line 28.

    E

     A runtime error occurs when line 25 executes.


    正确答案: E
    解析: 暂无解析

  • 第22题:

    多选题
    Given the following code fragment:     public void create() {     Vector myVect;     myVect = new Vector();      }  Which of the following statements are true?()
    A

    The declaration on line 2 does not allocate memory space for the variable myVect.

    B

    The declaration on line 2 allocates memory space for a reference to a Vector object.

    C

    The statement on line 2 creates an object of class Vector.

    D

    The statement on line 3 creates an object of class Vector.

    E

    The statement on line 3 allocates memory space for an object of class Vector.


    正确答案: C,D
    解析: SL-275中指出:要为一个新对象分配空间必须执行new Xxx()调用,new调用执行以下的操作: 
    1.为新对象分配空间并将其成员初始化为0或者null。 
    2.执行类体中的初始化。(例如在类中有一个成员声明int a=10;在第一步后a=0 ,执行到第二步后a=10)    
    3.执行构造函数。 
    4.变量被分配为一个到内存堆中的新对象的引用。

  • 第23题:

    单选题
    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?()
    A

     Point p = new Point();

    B

     Line.Point p = new Line.Point();

    C

     The Point class cannot be instatiated at line 15.

    D

     Line 1 = new Line() ; 1.Point p = new 1.Point();


    正确答案: B
    解析: 暂无解析