Recall & Review
beginner
What is primitive to object conversion in Java?
It is the process of converting a primitive data type (like int, double) into its corresponding wrapper class object (like Integer, Double). This allows primitives to be used where objects are required.touch_appClick to reveal answer
beginner
What is autoboxing in Java?
Autoboxing is the automatic conversion by the Java compiler of a primitive type into its corresponding wrapper class object when needed.touch_appClick to reveal answer
beginner
How do you manually convert an int primitive to an Integer object?
You can use the Integer constructor or the static method Integer.valueOf(int). For example: Integer obj = Integer.valueOf(5);
touch_appClick to reveal answer
intermediate
What is the difference between autoboxing and manual boxing?
Autoboxing is done automatically by the compiler, while manual boxing requires explicitly creating wrapper objects using constructors or valueOf methods.
touch_appClick to reveal answer
beginner
Why is primitive to object conversion useful in Java?
It allows primitives to be used in collections like ArrayList, which only accept objects, and enables use of methods defined in wrapper classes.
touch_appClick to reveal answer
Which of these is the wrapper class for the primitive type 'int'?
What does autoboxing do in Java?
Which method can be used to manually convert an int to an Integer?
Why can't primitives be added directly to an ArrayList?
What is manual boxing?
Explain what primitive to object conversion means and why it is important in Java.
Describe the difference between autoboxing and manual boxing with examples.
