0
0
Javaprogramming~15 mins

Primitive to object conversion in Java - Interactive Code Practice

Choose your learning style8 modes available
ads_clickPractice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to convert an int primitive to an Integer object.

Java
int num = 10;
Integer obj = [1];
🎯 Drag options to blanks, or click blank then click option
Anew Integer(num)
BInteger.valueOf(num)
Cint.valueOf(num)
DInteger.parseInt(num)
Attempts:
3 left
2fill in blank
medium

Complete the code to convert a double primitive to a Double object.

Java
double val = 5.5;
Double obj = [1];
🎯 Drag options to blanks, or click blank then click option
ADouble.parseDouble(val)
Bnew Double(val).doubleValue()
CDouble.valueOf(val)
DDouble.toString(val)
Attempts:
3 left
3fill in blank
hard

Fix the error in converting a boolean primitive to a Boolean object.

Java
boolean flag = true;
Boolean obj = [1];
🎯 Drag options to blanks, or click blank then click option
ABoolean.valueOf(flag)
BBoolean.parseBoolean(flag)
Cnew Boolean(flag).booleanValue()
DBoolean.toString(flag)
Attempts:
3 left
4fill in blank
hard

Fill both blanks to convert a char primitive to a Character object and print it.

Java
char ch = 'a';
Character obj = [1];
System.out.println([2]);
🎯 Drag options to blanks, or click blank then click option
ACharacter.valueOf(ch)
Bch
Cobj
Dnew Character(ch)
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a Float object from a float primitive, check equality, and print the result.

Java
float f1 = 3.14f;
Float obj1 = [1];
Float obj2 = [2];
boolean isEqual = obj1.[3](obj2);
System.out.println(isEqual);
🎯 Drag options to blanks, or click blank then click option
AFloat.valueOf(f1)
Bnew Float(f1)
Cequals
DFloat.parseFloat("3.14")
Attempts:
3 left