Complete the code to convert an int primitive to an Integer object.
int num = 10; Integer obj = [1];
new Integer(num) which is deprecated.int.valueOf(num) which is invalid.Integer.parseInt(num) which converts String to int, not int to Integer.Use Integer.valueOf(num) to convert an int primitive to an Integer object efficiently.
Complete the code to convert a double primitive to a Double object.
double val = 5.5; Double obj = [1];
Double.parseDouble(val) which returns primitive double.new Double(val).doubleValue() which returns primitive double, not object.Double.toString(val) which returns String.Double.valueOf(val) converts a double primitive to a Double object correctly.
Fix the error in converting a boolean primitive to a Boolean object.
boolean flag = true;
Boolean obj = [1];Boolean.parseBoolean(flag) which returns primitive boolean.new Boolean(flag).booleanValue() which returns primitive boolean.Boolean.toString(flag) which returns String.Boolean.valueOf(flag) correctly converts a boolean primitive to a Boolean object.
Fill both blanks to convert a char primitive to a Character object and print it.
char ch = 'a'; Character obj = [1]; System.out.println([2]);
ch instead of the object.new Character(ch).ch directly to Character without conversion.Use Character.valueOf(ch) to convert char to Character object, then print the object obj.
Fill all three blanks to create a Float object from a float primitive, check equality, and print the result.
float f1 = 3.14f; Float obj1 = [1]; Float obj2 = [2]; boolean isEqual = obj1.[3](obj2); System.out.println(isEqual);
Float.parseFloat which returns primitive float, not object.== instead of equals to compare objects.Use Float.valueOf(f1) and new Float(f1) to create Float objects, then use equals to compare them.
