itgle.com

单选题Given: When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()ALine 5BLine 6CLine 7DLine 8ELine 9FLine 10

题目
单选题
Given: When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()
A

Line 5

B

Line 6

C

Line 7

D

Line 8

E

Line 9

F

Line 10


相似考题
更多“单选题Given: When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()A Line 5B Line 6C Line 7D Line 8E Line 9F Line 10”相关问题
  • 第1题:

    1. class Test {  2. private Demo d;  3. void start() {  4. d = new Demo();  5. this.takeDemo(d); 6. }  7.   8. void takeDemo(Demo demo) {  9. demo = null;  10. demo = new Demo(); 11. }  12. }  When is the Demo object, created on line 3, eligible for garbage collection?()  

    • A、 After line 5.
    • B、 After line 9.
    • C、 After the start() method completes.
    • D、 When the takeDemo() method completes.
    • E、 When the instance running this code is made eligible for garbage collection.

    正确答案:E

  • 第2题:

    12. void start() {  13. A a = new A();  14. B b = new B();  15. a.s(b);  16. b = null;  17. a = null;  18. System.out.println(“start completed”); 19. }  When is the B object, created in line 14, eligible for garbage collection?()  

    • A、 After line 16.
    • B、 After line 17.
    • C、 After line 18 (when the methods ends).
    • D、 There is no way to be absolutely certain.
    • E、 The object is NOT eligible for garbage collection.

    正确答案:D

  • 第3题:

    1.public class GC{ 2.private Objec to; 3.private void doSomethingElse(Object obj){o=obj;} 4.public void doSomething(){ 5.Object o=new Object(); 6.doSomethingElse(o); 7.o=new Object(); 8.doSomethingElse(null); 9.o=null; 10.} 11.} When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()

    • A、Line5
    • B、Line6
    • C、Line7
    • D、Line8
    • E、Line9
    • F、Line10

    正确答案:D

  • 第4题:

    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;  10. 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).

    正确答案:C

  • 第5题:

    public class X {   public object m () {   object o = new float (3.14F);   object oa = new object [1];   oa[0]= o;   o = null;   oa[0] = null;   return o;   }   }   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).

    正确答案:C

  • 第6题:

    Which is the earliest line in the following code after which the object created on the line marked (0) will be a candidate for being garbage collected, assuming no compiler optimizations are done? ()  public class Q76a9 {   static String f() {   String a = "hello";   String b = "bye"; // (0)   String c = b + "!"; // (1)   String d = b;  b = a; // (2)   d = a; // (3)   return c; // (4)  }   public static void main(String args[]) {   String msg = f();   System.out.println(msg); // (5)   }   }  

    • A、The line marked (1).
    • B、The line marked (2).
    • C、The line marked (3).
    • D、The line marked (4).
    • E、The line marked (5).

    正确答案:C

  • 第7题:

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

  • 第8题:

    单选题
    1. public class GC {  2. private Object o;  3. private void doSomethingElse(Object obj) { o = obj; }  4. public void doSomething() {  5. Object o = new Object();  6. doSomethingElse(o);  7. o = new Object();  8. doSomethingElse(null);  9.o=null;  10. }  11. }  When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()
    A

     Line 5

    B

     Line 6

    C

     Line 7

    D

     Line 8

    E

     Line 9

    F

     Line 10


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

  • 第9题:

    单选题
    Given: When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()
    A

    Line 5

    B

    Line 6

    C

    Line 7

    D

    Line 8

    E

    Line 9

    F

    Line 10


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

  • 第10题:

    单选题
    Which is the earliest line in the following code after which the object created on the line marked (0) will be a candidate for being garbage collected, assuming no compiler optimizations are done? ()  public class Q76a9 {   static String f() {   String a = "hello";   String b = "bye"; // (0)   String c = b + "!"; // (1)   String d = b;  b = a; // (2)   d = a; // (3)   return c; // (4)  }   public static void main(String args[]) {   String msg = f();   System.out.println(msg); // (5)   }   }
    A

    The line marked (1).

    B

    The line marked (2).

    C

    The line marked (3).

    D

    The line marked (4).

    E

    The line marked (5).


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

  • 第11题:

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


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

  • 第12题:

    单选题
    12. void start() {  13. A a = new A();  14. B b = new B();  15. a.s(b);  16. b = null;  17. a = null;  18. System.out.println(“start completed”); 19. }  When is the B object, created in line 14, eligible for garbage collection?()
    A

     After line 16.

    B

     After line 17.

    C

     After line 18 (when the methods ends).

    D

     There is no way to be absolutely certain.

    E

     The object is NOT eligible for garbage collection.


    正确答案: B
    解析: The correct answer to this question is D. The member method s is not defined so there is no way to be certain of the result. 

  • 第13题:

    10. public Object m() { 11. Object o = new Float(3.14F); 12. Object [] oa = new Object[1]; 13. oa[0] = o; 14. o = null; 15. return oa[0]; 16. } When is the Float object, created in line 11, eligible for garbage collection?()  

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

    正确答案:C

  • 第14题:

    1. public class GC {  2. private Object o;  3. private void doSomethingElse(Object obj) { o = obj; }  4. public void doSomething() {  5. Object o = new Object();  6. doSomethingElse(o);  7. o = new Object();  8. doSomethingElse(null);  9.o=null;  10. }  11. }  When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?() 

    • A、 Line 5
    • B、 Line 6
    • C、 Line 7
    • D、 Line 8
    • E、 Line 9
    • F、 Line 10

    正确答案:D

  • 第15题:

    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. return oa[0];  8. }  9. }   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 (that is, as the method returns)
    • D、 Never in this method.

    正确答案:D

  • 第16题:

    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

  • 第17题:

    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

  • 第18题:

    单选题
    10. public Object m() { 11. Object o = new Float(3.14F); 12. Object [] oa = new Object[1]; 13. oa[0] = o; 14. o = null; 15. return oa[0]; 16. } When is the Float object, created in line 11, eligible for garbage collection?()
    A

     Just after line 13.

    B

     Just after line 14.

    C

     Never in this method.

    D

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


    正确答案: A
    解析: The correct answer to this question is C. The object is never garbage collected simply because the method returns it. Think about it, the message that receives the object might depend on it so it must be sure that the object received by the method wont be garbage collected. Only in this situation a local object  wont be eligible for garbage collection. Otherwise, a local object is eligible for garbage collection as soon as the method ends.

  • 第19题:

    单选题
    1.public class GC{ 2.private Objec to; 3.private void doSomethingElse(Object obj){o=obj;} 4.public void doSomething(){ 5.Object o=new Object(); 6.doSomethingElse(o); 7.o=new Object(); 8.doSomethingElse(null); 9.o=null; 10.} 11.} When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()
    A

    Line5

    B

    Line6

    C

    Line7

    D

    Line8

    E

    Line9

    F

    Line10


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

  • 第20题:

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

  • 第21题:

    单选题
    1. class Test {  2. private Demo d;  3. void start() {  4. d = new Demo();  5. this.takeDemo(d); 6. }  7.   8. void takeDemo(Demo demo) {  9. demo = null;  10. demo = new Demo(); 11. }  12. }  When is the Demo object, created on line 3, eligible for garbage collection?()
    A

     After line 5.

    B

     After line 9.

    C

     After the start() method completes.

    D

     When the takeDemo() method completes.

    E

     When the instance running this code is made eligible for garbage collection.


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

  • 第22题:

    单选题
    public class X {   public object m () {   object o = new float (3.14F);   object oa = new object [1];   oa[0]= o;   o = null;   oa[0] = null;   return o;   }   }   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).


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

  • 第23题:

    单选题
    public class X {  public object m () {   object o = new float (3.14F);   object oa = new object [1];   oa[0]= o;   o = null;   return oa[0];   }   }   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 (that is, as the method returns)

    D

     Never in this method.


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

  • 第24题:

    单选题
    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. return oa[0];  8. }  9. }   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 (that is, as the method returns)

    D

     Never in this method.


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