Java OCA OCP Practice Question 1423

Question

Given that Main is a class, how many objects and reference variables are created by the following code?

Main t1, t2, t3, t4; 
t1 = t2 = new Main (); 
t3 = new Main (); 

Select 1 option

  • A. 2 objects, 3 references.
  • B. 2 objects, 4 references.
  • C. 3 objects, 2 references.
  • D. 2 objects, 2 references.
  • E. None of the above.


Correct Option is  : B

Note

A declared reference variable exists regardless of whether a reference value (i.e. an object) has been assigned to it or not.




PreviousNext

Related