单选题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.
单选题
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.
参考解析
解析:
Java语言将内存分配和释放的工组交给了自己,程序员不必做这些工作,它提供一个系统级的线程跟踪每个内存的分配,在JVM的空闲处理中,垃圾收集线程将检查和释放不再使用的内存(即可以被释放的内存)。垃圾收集的过程在java程序的生存期中是自动的,不需要分配和释放内存,也避免了内存泄漏。可以调用System.gc()方法建议(suggest)JVM执行垃圾收集以使得可被释放的内存能立即被使用,当此方法返回的时候,JVM已经做了最大的努力从被丢弃的对象上回收内存空间。程序员不能指定收集哪些内存,一般而言也不用关心这个问题,除非是程序的内存消耗很大,特别是有很多临时对象时可以“建议“进行垃圾收集以提高可用内存。需要指出的是调用System.gc()方法不能保证JVM立即进行垃圾收集,而只能是建议,因为垃圾收集线程的优先级很低(通常是最低的)。
相关考题:
单选题1. interface DoStuff2 { 2. float getRange(int low, int high); } 3. 4. interface DoMore { 5. float getAvg(int a, int b, int c); } 6. 7. abstract class DoAbstract implements DoStuff2, DoMore { } 8. 9. class DoStuff implements DoStuff2 { 10. public float getRange(int x, int y) { return 3.14f; } } 11. 12. interface DoAll extends DoMore { 13. float getAvg(int a, int b, int c, int d); } What is the result?()A The file will compile without error.B Compilation fails. Only line 7 contains an error.C Compilation fails. Only line 12 contains an error.D Compilation fails. Only line 13 contains an error.E Compilation fails. Only lines 7 and 12 contain errors.F Compilation fails. Only lines 7 and 13 contain errors.G Compilation fails. Lines 7, 12, and 13 contain errors.
单选题1. import java.util.*; 2. public class Example { 3. public static void main(String[] args) { 4. // insert code here 5. set.add(new integer(2)); 6. set.add(new integer(l)); 7. System.out.println(set); 8. } 9. } Which code, inserted at line 4, guarantees that this program will output [1,2]? ()A Set set = new TreeSet();B Set set = new HashSet();C Set set = new SortedSet();D List set = new SortedList();E Set set = new LinkedHashSet();
单选题public class Alpha{ public static void main( string[] args ){ if ( args.length == 2 ) { if ( args.[0].equalsIgnoreCase(“-b”) ) System.out.println( new Boolean( args[1] )); } } } And the code is invoked by using the command: java Alpha –b TRUE What is the result?()A trueB nullC falseD Compilation fails.E The code runs with no output.F An exception is thrown at runtime.
单选题What will be written to the standard output when the following program is run?() public class Q03e4 { public static void main(String args[]) { String space = " "; String composite = space + "hello" + space + space; composite.concat("world"); String trimmed = composite.trim(); System.out.println(trimmed.length()); } }A5B6C7D12E13
单选题1. package foo; 2. 3. import java.util.Vector; 4. 5. private class MyVector extends Vector { 6. int i = 1; 7. public MyVector() { 8. i = 2; 9. } 10. } 11. 12. public class MyNewVector extends MyVector { 13. public MyNewVector () { 14. i = 4; 15. } 16. public static void main (String args []) { 17. MyVector v = new MyNewVector(); 18. } 19. } The file MyNewVector.java is shown in the exhibit. What is the result?()A Compilation will succeed.B Compilation will fail at line 5.C Compilation will fail at line 6.D Compilation will fail at line 14.E Compilation will fail at line 17.