单选题How can you force garbage collection of an object?()AGarbage collection cannot be forced.BCall System.gc().CCall System.gc(), passing in a reference to the object to be garbage collected.DCall Runtime.gc().ESet all references to the object to new value

题目
单选题
How can you force garbage collection of an object?()
A

 Garbage collection cannot be forced.

B

 Call System.gc().

C

 Call System.gc(), passing in a reference to the object to be garbage collected.

D

 Call Runtime.gc().

E

 Set all references to the object to new values(null, for example).


相似考题
更多“How can you force garbage collection of an object?()”相关问题
  • 第1题:

    1. class TestA {  2. TestB b;  3. TestA() {  4. b = new TestB(this);  5. }  6. }  7. class TestB {  8. TestA a;  9. TestB(TestA a) {  10. this.a = a;  11. }  12. }  13. class TestAll {  14. public static void main (String args[]) {  15. new TestAll().makeThings(); 16. // ...code continues on  17. }  18. void makeThings() {  19. TestA test = new TestA(); 20. }  21. }  Which two statements are true after line 15, before main completes?()

    • A、 Line 15 causes a stack overflow.
    • B、 An exception is thrown at runtime.
    • C、 The object referenced by a is eligible for garbage collection.
    • D、 The object referenced by b is eligible for garbage collection.
    • E、 The object referenced by a is not eligible for garbage collection.
    • F、 The object referenced by b is not eligible for garbage collection.

    正确答案:C,D

  • 第2题:

    What allows the programmer to destroy an object x?()  

    • A、 x.delete()
    • B、 x.finalize()
    • C、 Runtime.getRuntime().gc()
    • D、 Explicitly setting the object’s reference to null.
    • E、 Ensuring there are no references to the object.
    • F、 Only the garbage collection system can destroy an object.

    正确答案:F

  • 第3题:

    Which statements describe guaranteed behavior of the garbage collection and finalization mechanisms?()  

    • A、Objects are deleted when they can no longer be accessed through any reference.
    • B、The finalize() method will eventually be called on every object.
    • C、The finalize() method will never be called more than once on an object.
    • D、An object will not be garbage collected as long as it is possible for an active part of the program to      access it through a reference.
    • E、The garbage collector will use a mark and sweep algorithm.

    正确答案:C,D

  • 第4题:

    Which statements about the garbage collection are true?() 

    • A、 The program developer must create a thread to be responsible for free the memory.
    • B、 The garbage collection will check for and free memory no longer needed.
    • C、 The garbage collection allow the program developer to explicity and immediately free the memory.
    • D、 The garbage collection can free the memory used java object at expect time.

    正确答案:B

  • 第5题:

    You use Microsoft .NET Framework 4 to create a Windows Presentation Foundation (WPF) application. You add a ListBox control to the application. The ListBox control is data-bound to an instance of a custom collection class of the Product objects named ProductList. The number of items of the data-bound collection is fixed. However, users can modify the properties of each of the Product objects in the collection. You need to ensure that changes made on the Product objects are automatically reflected in the ListBox control. What should you do?()

    • A、 Implement the INotifyPropertyChanged interface in the Product class.
    • B、 Implement the INotifyCollectionChanged interface in the ProductList class.
    • C、 Set the Mode property of the Binding object of the ListBox control to TwoWay.
    • D、  Set the UpdateSourceTrigger property of the Binding object of the ListBox control to PropertyChanged.

    正确答案:A

  • 第6题:

    单选题
    11. class Snoochy {  12. Boochybooch;  13. public Snoochy() { booch = new Boochy(this); }  14. }  15.  16. class Boochy {  17. Snoochy snooch;  18. public Boochy(Snoochy s) { snooch = s; }  19. }  And the statements:  21. public static void main(String[] args) {  22. Snoochy snoog = new Snoochy();  23. snoog = null;  24. // more code here  25. }  Which statement is true about the objects referenced by snoog, snooch, and booch immediately after line 23 executes?()
    A

     None of these objects are eligible for garbage collection.

    B

     Only the object referenced by booch is eligible for garbage collection.

    C

     Only the object referenced by snoog is eligible for garbage collection.

    D

     Only the object referenced by snooch is eligible for garbage collection.

    E

     The objects referenced by snooch and booch are eligible for garbage collection.


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

  • 第7题:

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


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

  • 第8题:

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

  • 第9题:

    单选题
    How can you force garbage collection of an object?()
    A

     Garbage collection cannot be forced.

    B

     Call System.gc().

    C

     Call System.gc(), passing in a reference to the object to be garbage collected.

    D

     Call Runtime.gc().

    E

     Set all references to the object to new values(null, for example).


    正确答案: A
    解析: 在Java中垃圾收集是不能被强迫立即执行的。调用System.gc()或Runtime.gc()静态方法不能保证垃圾收集器的立即执行,因为,也许存在着更高优先级的线程。所以选项B、D不正确。选项C的错误在于,System.gc()方法是不接受参数的。选项E中的方法可以使对象在下次垃圾收集器运行时被收集。

  • 第10题:

    单选题
    Which statements about the garbage collection are true?()
    A

     The program developer must create a thread to be responsible for free the memory.

    B

     The garbage collection will check for and free memory no longer needed.

    C

     The garbage collection allow the program developer to explicity and immediately free the memory.

    D

     The garbage collection can free the memory used java object at expect time.


    正确答案: A
    解析: Java语言将内存分配和释放的工组交给了自己,程序员不必做这些工作,它提供一个系统级的线程跟踪每个内存的分配,在JVM的空闲处理中,垃圾收集线程将检查和释放不再使用的内存(即可以被释放的内存)。垃圾收集的过程在java程序的生存期中是自动的,不需要分配和释放内存,也避免了内存泄漏。可以调用System.gc()方法建议(suggest)JVM执行垃圾收集以使得可被释放的内存能立即被使用,当此方法返回的时候,JVM已经做了最大的努力从被丢弃的对象上回收内存空间。程序员不能指定收集哪些内存,一般而言也不用关心这个问题,除非是程序的内存消耗很大,特别是有很多临时对象时可以“建议“进行垃圾收集以提高可用内存。需要指出的是调用System.gc()方法不能保证JVM立即进行垃圾收集,而只能是建议,因为垃圾收集线程的优先级很低(通常是最低的)。

  • 第11题:

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


    正确答案: C
    解析: 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. 

  • 第12题:

    单选题
    You are a network administrator for Your network consists of a single Active Directory domain named All servers run Windows Server 2003. A help desk user reports that a user object was accidentally deleted and the user can no longer log on to the domain and access resources. You confirm that the user object was included in the most recent backup. You need to enable the user to log on to the domain. You must ensure that the user retains access to resources. What should you do?()
    A

    Install a new domain controller. Install Active Directory from media by using the most recent backup. Manually initiate replication.

    B

    Decrease the garbage collection interval. Perform a nonauthorative restoration of Active Directory by using the most recent backup.

    C

    Perform a nonauthorative restoration of Active Directory by using the most recent backup. Authoritatively restore the user object that was deleted.

    D

    Re-create a user object that has the same user principal name (UPN) as the user object that was deleted. Authoritatively restore this user object.


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

  • 第13题:

    How can you force garbage collection of an object?()

    • A、 Garbage collection cannot be forced.
    • B、 Call System.gc().
    • C、 Call System.gc(), passing in a reference to the object to be garbage collected.
    • D、 Call Runtime.gc().
    • E、 Set all references to the object to new values(null, for example).

    正确答案:A

  • 第14题:

    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

  • 第15题:

    Which statement is true about XpauseTarget in Oracle JRockit JVM ? ()

    • A、 This option is supported by all type of Garbage collection modes.
    • B、 This option is only supported by Generational Garbage Collection mode.
    • C、 This option is only supported by Mark and Sweep Garbage Collection mode.
    • D、 This option is only supported by Dynamic Garbage Collection mode.

    正确答案:D

  • 第16题:

    Oracle JRockit JVM uses -Xns option to set nursery size when the generational garbage collection mode is used.  Which two JVM properties are affected by changing its size ?()

    • A、 compaction ratio limit
    • B、 garbage collection frequency
    • C、 garbage collection times
    • D、 fragmentation heap size

    正确答案:B,C

  • 第17题:

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


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

  • 第18题:

    单选题
    What allows the programmer to destroy an object x?()
    A

     x.delete()

    B

     x.finalize()

    C

     Runtime.getRuntime().gc()

    D

     Explicitly setting the object’s reference to null.

    E

     Ensuring there are no references to the object.

    F

     Only the garbage collection system can destroy an object.


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

  • 第19题:

    单选题
    Which statement is true about XpauseTarget in Oracle JRockit JVM ? ()
    A

     This option is supported by all type of Garbage collection modes.

    B

     This option is only supported by Generational Garbage Collection mode.

    C

     This option is only supported by Mark and Sweep Garbage Collection mode.

    D

     This option is only supported by Dynamic Garbage Collection mode.


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

  • 第20题:

    多选题
    1. class TestA {  2. TestB b;  3. TestA() {  4. b = new TestB(this);  5. }  6. }  7. class TestB {  8. TestA a;  9. TestB(TestA a) {  10. this.a = a;  11. }  12. }  13. class TestAll {  14. public static void main (String args[]) {  15. new TestAll().makeThings(); 16. // ...code continues on  17. }  18. void makeThings() {  19. TestA test = new TestA(); 20. }  21. }  Which two statements are true after line 15, before main completes?()
    A

    Line 15 causes a stack overflow.

    B

    An exception is thrown at runtime.

    C

    The object referenced by a is eligible for garbage collection.

    D

    The object referenced by b is eligible for garbage collection.

    E

    The object referenced by a is not eligible for garbage collection.

    F

    The object referenced by b is not eligible for garbage collection.


    正确答案: C,F
    解析: This is a typical example of the island of isolation. On line 15, the two objects TestA and TestB have a reference to one an other. Therefore, the correct answers are C. and D. A key point to remember is that an object that is referenced by another object can be eligible for garbage collection if the two objects form an island of isolated objects. 

  • 第21题:

    单选题
    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


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

  • 第22题:

    多选题
    class A {  }  class Alpha {  private A myA = new A();  void dolt( A a ) {  a = null;  }  void tryIt() {  dolt( myA );  }  }  Which two statements are correct?()
    A

    There are no instanced of A that will become eligible for garbage collection.

    B

    Explicitly setting myA to null marks that instance to be eligible for garbage collection.

    C

    Any call on tryIt() causes the private instance of A to be marked for garbage collection.

    D

    Private instances of A become eligible for garbage collection when instances of Alpha become eligible for garbage collection.


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

  • 第23题:

    多选题
    Which statements describe guaranteed behavior of the garbage collection and finalization mechanisms?()
    A

    Objects are deleted when they can no longer be accessed through any reference.

    B

    The finalize() method will eventually be called on every object.

    C

    The finalize() method will never be called more than once on an object.

    D

    An object will not be garbage collected as long as it is possible for an active part of the program to      access it through a reference.

    E

    The garbage collector will use a mark and sweep algorithm.


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

  • 第24题:

    单选题
    11.class Snoochy{ 12.Boochybooch; 13.public Snoochy(){booch=newBoochy(this);} 14.} 15. 16.class Boochy{ 17.Snoochy snooch; 18.public Boochy(Snoochys){snooch=s;} 19.} And the statements: 21.public static void main(String[]args){ 22.Snoochy snoog=new Snoochy(); 23.snoog=null; 24.//more code here 25.} Which statement is true about the objects referenced by snoog,snooch,and booch immediately after line 23 executes?()
    A

    None of these objects are eligible for garbage collection.

    B

    Only the object referenced by booch is eligible for garbage collection.

    C

    Only the object referenced by snoog is eligible for garbage collection.

    D

    Only the object referenced by snooch is eligible for garbage collection.

    E

    The objects referenced by snooch and booch are eligible for garbage collection.


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