Java OCA OCP Practice Question 940

Question

Suppose prim is an int and wrapped is an Integer.

Which of the following are legal Java statements?

Choose all that apply.

  • A. prim = wrapped;
  • B. wrapped = prim;
  • C. prim = new Integer(9);
  • D. wrapped = 9;


A, B, C, D.

Note

All four statements are legal, thanks to boxing and unboxing.




PreviousNext

Related