Java OCA OCP Practice Question 292

Question

Fill in the blanks to indicate whether a primitive or wrapper class can be assigned without the compiler using the autoboxing feature.

first = Integer.parseInt("5"); 
second = Integer.valueOf("5"); 
  • A. int, int
  • B. int, Integer
  • C. Integer, int
  • D. Integer, Integer


B.

Note

The parseInt() methods return a primitive.

The valueOf() methods return a wrapper class object.

In real code, autoboxing would let you assign the return value to either a primitive or wrapper class.

In terms of what gets returned directly, Option B is correct.




PreviousNext

Related