Multiple Choice Question

Quiz Guidelines

 

QID: 
115
Question: 

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.

Q&A Set: