What will be the result of attempting to compile and run the following program?
public class TestClass{
public static void main(String args[ ] ){
Object a, b, c ;
a = new String("A");
b = new String("B");
c = a;
a = b;
System.out.println(""+c);
}
}
Select 1 option
A. The program will print java.lang.String@XXX, where XXX is the memory location of the object a.
B. The program will print A
C. The program will print B
D. The program will not compile as a,b and c are of type Object.
E. The program will print java.lang.String@XXX, where XXX is the hash code of the object a.
If you want to solve the questions together with the experts and understand the concepts better, please contact us using the contact form or WhatsApp numbers. Selected people get to do that without any additional charges.