Java OCA OCP Practice Question 1068

Question

Which of the following code snippets compile?

  • A. Integer i = 7;
  • B. Integer i = new Integer(5); int j = i;
  • C. byte b = 7;
  • D. int i = 7; byte b = i;
  • E. None of the above


A, B, C.

Note

A and B are examples of 5.0's boxing and unboxing functionality.

C is a legal assignment, but D is an illegal assignment that requires a cast;




PreviousNext

Related