Source : javablackbelf.com 1) If a Runtime Exception is thrown in the finalize method
a)The running application crashes. b)The exception is simply ignored and the object is garbage collected. c)The exception is simply ignored, but the object is not garbage collected. d)The Exception causes the JVM to crash.
My Answer is : d). JVM wont collect the object when the runtime exception occurs. Then it garbage collects it next time wihtout calling the finalize() method.
correct answer given is : b)
2) When does the JVM exit?
a)After the main method returns. b)After all the non-daemon threads created by the application complete. c)After all the daemon threads created by the application complete d)When a thread executes System.exit(); e)When an uncaught exception is thrown in a non-demon thread. f)When an uncaught exception is thrown in a demon thread.
As to the first question, nothing should cause the JVM to crash.
From the javadocs of Object.finalize: Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored. In particular, it doesn't prevent GC'ing it. [ June 13, 2008: Message edited by: Ulf Dittmer ]