Given:
3. public class Main { 4. static Main bd; 5. public static void main(String[] args) { 6. new Main().doShape(); 7. // do lots of memory intensive stuff ... // JVM finds an eligible Main object for GC ... // JVM invokes finalize() ... // do more stuff 48. } /*ww w .j a v a2 s. c om*/ 49. void doShape() { } 50. // insert code here 51. bd = this; 52. } 53. } 54. class MyException extends Exception { }
and the following four fragments:
finalize()
throws Throwable {finalize()
{finalize()
throws MyException {finalize()
{If the fragments are inserted, independently, at line 50, which are true? (Choose all that apply.)
finalize()
on that object.finalize()
has been overridden, the GC will never collect eligible objects of type Main.A, B, and C are correct
A, B, and C are correct because Fragments I-III are legal signatures to override finalize()
.
D is incorrect because the access privilege is weaker.
E is incorrect because finalize()
copies a reference of the object to the static variable bd.
F is incorrect.
For a given object, the JVM will never call finalize()
again, but it might still GC it.