0
0
Javaprogramming~15 mins

Primitive to object conversion in Java - Practice Problems & Coding Challenges

Choose your learning style8 modes available
trophyChallenge - 5 Problems
🎖️
Primitive to Object Conversion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 code output
intermediate
2:00remaining
Output of autoboxing with Integer
What is the output of this Java code snippet?
Java
Integer a = 1000;
Integer b = 1000;
System.out.println(a == b);
Atrue
Bfalse
CCompilation error
DRuntime exception
Attempts:
2 left
💻 code output
intermediate
2:00remaining
Unboxing and arithmetic with Integer and int
What is the output of this Java code?
Java
Integer x = 5;
int y = 10;
System.out.println(x + y);
A15
BCompilation error
C5 10
DNullPointerException
Attempts:
2 left
🔧 debug
advanced
2:00remaining
Identify the error in primitive to object conversion
Which option will cause a compilation error in this code snippet?
Java
Double d = 10.5;
Integer i = d;
ADouble d = 10.5; Integer i = (int) d.doubleValue();
BDouble d = 10.5; Integer i = d.intValue();
CDouble d = 10.5; int i = d.intValue();
DDouble d = 10.5; Integer i = d;
Attempts:
2 left
📝 syntax
advanced
2:00remaining
Correct way to convert int to Integer
Which option correctly converts a primitive int to an Integer object?
AInteger obj = (Integer) 5;
BInteger obj = 5;
CInteger obj = Integer.valueOf(5);
DInteger obj = new Integer(5);
Attempts:
2 left
🚀 application
expert
3:00remaining
Predict the output with mixed primitive and wrapper types
What is the output of this Java code?
Java
Integer a = 127;
Integer b = 127;
Integer c = 128;
Integer d = 128;
System.out.println(a == b);
System.out.println(c == d);
A
true
false
B
false
false
C
true
true
D
false
true
Attempts:
2 left