In an interview i was asked,suppose JVM runs gc when object of class A is not in used.
class A{
//some code here
protected void finalize(){
//code here
}
}
does it guarantee the execution of finalize(). I said yes
The next ques was if obj of Class A is being used, if now JVM runs GC does it execute finalize(). I said no, it'll not execute this finalize() as JVM does not collect A's object.
However she did not comment anything but looked disappointed.
Does i interpret it wrong? Thanks in Advance