单选题Given:  Which code, inserted at line 15, creates an instance of the Point class defined in Line?()ALine l = new Line() ; l.Point p = new l.Point();BLine.Point p = new Line.Point();CThe Point class cannot be instatiated at line 15.DPoint p = new Point()

题目
单选题
Given:  Which code, inserted at line 15, creates an instance of the Point class defined in Line?()
A

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

B

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

C

 The Point class cannot be instatiated at line 15.

D

 Point p = new Point();


相似考题
更多“单选题Given:  Which code, inserted at line 15, creates an instance of the Point class defined in Line?()A  Line l = new Line() ; l.Point p = new l.Point();B  Line.Point p = new Line.Point();C  The Point class cannot be instatiated at line 15.D  Point p =”相关问题
  • 第1题:

    Given: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

  • 第2题:

    class Super {  public int getLenght( ) { return 4; }  }  public class Sub extends Super {  public long getLenght( ) { return 5; }  public static void main(String[] args) {  Super sooper = new Super( );  Sub sub = new Sub( );  System.out.println(  sooper.getLenght( ) + “,” + sub.getLenght( ) );  }  } What is the output?()

    • A、 Just after line 13.
    • B、 Just after line 14.
    • C、 Just after line 15.
    • D、 Just after line 16 (that is, as the method returns).

    正确答案:C

  • 第3题:

    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

  • 第4题:

    Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.   class Base {   public void print( ) {   System.out.println("base");   }   }   class Extention extends Base {   public void print( ) {   System.out.println("extension");   // insert line of implementation here   }   }   public class Q294d {   public static void main(String args[]) {   Extention ext = new Extention( );   ext.print( );   }   }   Fill in a single line of implementation.()


    正确答案:super.print();

  • 第5题:

    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

  • 第6题:

    单选题
    1. public class Outer{  2. public void someOuterMethod() {  3. // Line 3  4. }  5. public class Inner{}  6. public static void main( String[]argv ) {  7. Outer o = new Outer();  8. // Line 8  9. }  10. }  Which instantiates an instance of Inner?()
    A

     new Inner(); // At line 3

    B

     new Inner(); // At line 8

    C

     new o.Inner(); // At line 8

    D

     new Outer.Inner(); // At line 8


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

  • 第7题:

    单选题
    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
    解析: 暂无解析

  • 第8题:

    单选题
    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
    解析: 暂无解析

  • 第9题:

    单选题
    Given:   11. public void genNumbers() {   12. ArrayList numbers = new ArrayList();   13. for (int i=0; i<10; i++) { 14. int value = i * ((int) Math.random());   15. Integer intObj = new Integer(value);   16. numbers.add(intObj);   17. }   18. System.out.println(numbers);   19. }   Which line of code marks the earliest point that an object referenced by intObj becomes a  candidate for garbage collection?()
    A

     Line 19

    B

     The object is NOT a candidate for garbage collection.

    C

     Line 17

    D

     Line 16

    E

     Line 18


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

  • 第10题:

    单选题
    1. class Bar { }  1. class Test {  2. Bar doBar() {  3. Bar b = new Bar();  4. return b;  5. }  6. public static void main (String args[]) {  7. Test t = new Test();  8. Bar newBar = t.doBar();  9. System.out.println(“newBar”);  10. newBar = new Bar();  11. System.out.println(“finishing”);  12. }  13. } At what point is the Bar object, created on line 3, eligible for garbage collection?()
    A

     After line 8.

    B

     After line 10.

    C

     After line 4, when doBar() completes.

    D

     After line 11, when main() completes.


    正确答案: B
    解析: The correct answer is B. When a local object is returned, it is not yet available for garbage collection. For this reason, the object is only available for garbage collecting at line 10, where the only remaining reference to the object is replaced with an other object.

  • 第11题:

    多选题
    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
    解析: 暂无解析

  • 第12题:

    单选题
    11. public void genNumbers() {  12. ArrayList numbers = new ArrayList();  13. for (int i=0; i<10; i++) {  14. int value = i * ((int) Math.random());  15. Integer intObj = new Integer(value);  16. numbers.add(intObj);  17. }  18. System.out.println(numbers);  19. }  Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()
    A

     Line 16

    B

     Line 17

    C

     Line 18

    D

     Line 19

    E

     The object is NOT a candidate for garbage collection.


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

  • 第13题:

    1. public class Outer{  2. public void someOuterMethod() {  3. // Line 3  4. }  5. public class Inner{}  6. public static void main( String[]argv ) {  7. Outer o = new Outer();  8. // Line 8  9. }  10. }  Which instantiates an instance of Inner?()  

    • A、 new Inner(); // At line 3
    • B、 new Inner(); // At line 8
    • C、 new o.Inner(); // At line 8
    • D、 new Outer.Inner(); // At line 8

    正确答案:A

  • 第14题:

    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

  • 第15题:

    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

  • 第16题:

    1. class Bar { }  1. class Test {  2. Bar doBar() {  3. Bar b = new Bar();  4. return b;  5. }  6. public static void main (String args[]) {  7. Test t = new Test();  8. Bar newBar = t.doBar();  9. System.out.println(“newBar”);  10. newBar = new Bar();  11. System.out.println(“finishing”);  12. }  13. } At what point is the Bar object, created on line 3, eligible for garbage collection?()  

    • A、 After line 8.
    • B、 After line 10.
    • C、 After line 4, when doBar() completes.
    • D、 After line 11, when main() completes.

    正确答案:B

  • 第17题:

    Given:   11. public void genNumbers() {   12. ArrayList numbers = new ArrayList();   13. for (int i=0; i<10; i++) { 14. int value = i * ((int) Math.random());   15. Integer intObj = new Integer(value);   16. numbers.add(intObj);   17. }   18. System.out.println(numbers);   19. }   Which line of code marks the earliest point that an object referenced by intObj becomes a  candidate for garbage collection?()

    • A、 Line 19
    • B、 The object is NOT a candidate for garbage collection.
    • C、 Line 17
    • D、 Line 16
    • E、 Line 18

    正确答案:A

  • 第18题:

    单选题
    Given: Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()
    A

    Line 16

    B

    Line 17

    C

    Line 18

    D

    Line 19


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

  • 第19题:

    单选题
    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
    解析: 第8行的getValue()试图访问父类的私有变量,错误。

  • 第20题:

    多选题
    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.变量被分配为一个到内存堆中的新对象的引用。

  • 第21题:

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


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

  • 第22题:

    单选题
    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
    解析: 暂无解析

  • 第23题:

    单选题
    class Super {  public int getLenght( ) { return 4; }  }  public class Sub extends Super {  public long getLenght( ) { return 5; }  public static void main(String[] args) {  Super sooper = new Super( );  Sub sub = new Sub( );  System.out.println(  sooper.getLenght( ) + “,” + sub.getLenght( ) );  }  } What is the output?()
    A

     Just after line 13.

    B

     Just after line 14.

    C

     Just after line 15.

    D

     Just after line 16 (that is, as the method returns).


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