Java OCA OCP Practice Question 644

Question

Consider the following lines of code:

Integer i = new Integer (42); 
Long v = new Long (42); 
Double d = new Double (42.0); 

Which of the following options are valid?

Select 3 options

  • A. i == v;
  • B. v == d;
  • C. i.equals (d);
  • D. d.equals (v);
  • E. v.equals (42);


Correct Options are  : C D E

Note

If the compiler can figure out that something can NEVER happen, then it flags an error.

The compiler knows that v, i or d can never point to the same object in any case because they are references to different classes of objects that have no relation between themselves.




PreviousNext

Related