Question: class B { private String name; public B(String s) { name = s; } public void finalize() { System.out.print(name); } } 10 class E {
class B {
private String name;
public B(String s) {
name = s;
}
public void finalize() {
System.out.print(name);
}
}
10
class E {
public static void m() {
B x1 = new B("X"), y1 = new B("Y");
}
public static void main(String[] args) {
m();
System.gc();
}
}
If the above is stored in a file called E.java, which 2 of the following could be a result of attempting to compile and run the program?
Prints: XY
Prints: YX
Prints: XXYY
Nothing is printed.
None of the above
Compilation error
An exception is thrown
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
