0
0
Javaprogramming~15 mins

Common wrapper methods in Java - Practice Problems & Coding Challenges

Choose your learning style8 modes available
trophyChallenge - 5 Problems
🎖️
Wrapper Methods Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 code output
intermediate
2:00remaining
Output of Integer wrapper method usage
What is the output of the following Java code snippet using Integer wrapper methods?
Java
public class Main {
    public static void main(String[] args) {
        Integer num = Integer.valueOf("123");
        int result = num.intValue() + Integer.parseInt("77");
        System.out.println(result);
    }
}
ACompilation error
B100
C200
D12377
Attempts:
2 left
💻 code output
intermediate
2:00remaining
Output of Double wrapper method usage
What will be printed by this Java code using Double wrapper methods?
Java
public class Main {
    public static void main(String[] args) {
        Double d1 = Double.valueOf("10.5");
        double d2 = Double.parseDouble("2.5");
        System.out.println(d1.doubleValue() * d2);
    }
}
A26.25
B105.0
C13.0
DRuntime error
Attempts:
2 left
💻 code output
advanced
2:00remaining
Output of Boolean wrapper method usage
What is the output of this Java code snippet using Boolean wrapper methods?
Java
public class Main {
    public static void main(String[] args) {
        Boolean b1 = Boolean.valueOf("true");
        Boolean b2 = Boolean.valueOf("False");
        System.out.println(b1 && b2);
    }
}
Afalse
BRuntime exception
CCompilation error
Dtrue
Attempts:
2 left
💻 code output
advanced
2:00remaining
Output of Character wrapper method usage
What will this Java code print when using Character wrapper methods?
Java
public class Main {
    public static void main(String[] args) {
        Character ch = Character.valueOf('a');
        System.out.println(Character.toUpperCase(ch));
    }
}
ACompilation error
Ba
CRuntime exception
DA
Attempts:
2 left
💻 code output
expert
2:00remaining
Output of complex wrapper method chaining
What is the output of this Java code using multiple wrapper methods?
Java
public class Main {
    public static void main(String[] args) {
        String s = "256";
        Integer i = Integer.valueOf(s);
        Double d = Double.valueOf(i.doubleValue() / 4);
        System.out.println(d.intValue() + ":" + d);
    }
}
A64:64
B64:64.0
C64.0:64.0
DCompilation error
Attempts:
2 left