0
0
Javaprogramming~15 mins

Unboxing in Java - Practice Problems & Coding Challenges

Choose your learning style8 modes available
trophyChallenge - 5 Problems
🎖️
Unboxing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 code output
intermediate
2:00remaining
What is the output of this unboxing example?
Consider the following Java code. What will be printed when it runs?
Java
Integer a = 1000;
int b = a;
System.out.println(b == a);
Atrue
BRuntime exception
CCompilation error
Dfalse
Attempts:
2 left
💻 code output
intermediate
2:00remaining
What is the output when comparing Integer objects with ==?
What will this Java code print?
Java
Integer x = 127;
Integer y = 127;
System.out.println(x == y);
Integer m = 128;
Integer n = 128;
System.out.println(m == n);
A
false
false
B
true
true
C
true
false
D
false
true
Attempts:
2 left
🔧 debug
advanced
2:00remaining
Identify the runtime error caused by unboxing
What error will this code produce when run?
Java
Integer a = null;
int b = a;
System.out.println(b);
ANullPointerException
BCompilation error
CPrints 0
DNo output, infinite loop
Attempts:
2 left
💻 code output
advanced
2:00remaining
What is the output of this mixed boxing and unboxing code?
Analyze the output of this Java code snippet:
Java
Integer i = 10;
int j = 10;
System.out.println(i.equals(j));
System.out.println(i == j);
A
false
false
B
true
true
C
true
false
D
false
true
Attempts:
2 left
🧠 conceptual
expert
3:00remaining
How many Integer objects are created in this code?
Consider this Java code snippet. How many distinct Integer objects are created during execution?
Java
Integer a = 100;
Integer b = 100;
Integer c = new Integer(100);
Integer d = Integer.valueOf(100);
Integer e = 200;
Integer f = 200;
A4
B5
C3
D6
Attempts:
2 left