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


参考解析

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

相关考题:

——() ? —— I want to buy a pair of shoes. A. What are you doing?B. What can I do for you?C. How can I help you?D. How can I do for you?

how to operate incinerator ? what kind of garbage can not be thrown into incinerator ?

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.

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 5B、 Just after line 6C、 Just after line 7 (that is, as the method returns)D、 Never in this method.

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.

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

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.

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.

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.

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.

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.

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 limitB、 garbage collection frequencyC、 garbage collection timesD、 fragmentation heap size

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.

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

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

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

单选题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 5B Just after line 6C Just after line 7 (that is, as the method returns)D Never in this method.

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

单选题Given:   11. public void genNumbers() {   12. ArrayList numbers = new ArrayList();   13. for (int i=0; i10; 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 19B The object is NOT a candidate for garbage collection.C Line 17D Line 16E Line 18

多选题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?()ALine 15 causes a stack overflow.BAn exception is thrown at runtime.CThe object referenced by a is eligible for garbage collection.DThe object referenced by b is eligible for garbage collection.EThe object referenced by a is not eligible for garbage collection.FThe object referenced by b is not eligible for garbage collection.

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

单选题Given: Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()A Line 16B Line 17C Line 18D Line 19

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

多选题class A {  }  class Alpha {  private A myA = new A();  void dolt( A a ) {  a = null;  }  void tryIt() {  dolt( myA );  }  }  Which two statements are correct?()AThere are no instanced of A that will become eligible for garbage collection.BExplicitly setting myA to null marks that instance to be eligible for garbage collection.CAny call on tryIt() causes the private instance of A to be marked for garbage collection.DPrivate instances of A become eligible for garbage collection when instances of Alpha become eligible for garbage collection.

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

多选题Which statements describe guaranteed behavior of the garbage collection and finalization mechanisms?()AObjects are deleted when they can no longer be accessed through any reference.BThe finalize() method will eventually be called on every object.CThe finalize() method will never be called more than once on an object.DAn 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.EThe garbage collector will use a mark and sweep algorithm.

单选题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?()AInstall a new domain controller. Install Active Directory from media by using the most recent backup. Manually initiate replication.BDecrease the garbage collection interval. Perform a nonauthorative restoration of Active Directory by using the most recent backup.CPerform a nonauthorative restoration of Active Directory by using the most recent backup. Authoritatively restore the user object that was deleted.DRe-create a user object that has the same user principal name (UPN) as the user object that was deleted. Authoritatively restore this user object.

单选题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?()ANone of these objects are eligible for garbage collection.BOnly the object referenced by booch is eligible for garbage collection.COnly the object referenced by snoog is eligible for garbage collection.DOnly the object referenced by snooch is eligible for garbage collection.EThe objects referenced by snooch and booch are eligible for garbage collection.