Which scenario cannot definitely be the result of compiling and running the following program?
public class Main { private char v; Main(char v) { this.v = v; }// w ww .j a v a2 s .co m public void finalize() throws Throwable { System.out.print(v); super.finalize(); } public static void main(String[] args) { new Main('A'); new Main('F'); System.gc(); } }
Select the one correct answer.
(e)
It is not guaranteed if and when the garbage collection will be run, nor in which order the objects will be finalized.
However, it is guaranteed that the finalization of an object will only be run once, hence (e) cannot possible be a result from running the program.