Java SE 11 Developer — Question 14

Which two are successful examples of autoboxing? (Choose two.)

Answer options

Correct answer: A, B

Explanation

Options A and B are correct because autoboxing involves converting a primitive type into its corresponding wrapper class, and in these cases, the integer 5 is automatically converted to an Integer object, and the string 'A' is a valid assignment. Options C, D, E, and F either do not involve autoboxing or contain invalid assignments, such as using null with Float.valueOf or directly assigning a primitive to a wrapper without autoboxing.