0
0
Javaprogramming~15 mins

Parsing numeric arguments in Java - Practice Problems & Coding Challenges

Choose your learning style8 modes available
trophyChallenge - 5 Problems
🎖️
Parsing Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 code output
intermediate
2:00remaining
What is the output of parsing a valid integer string?
Consider the following Java code snippet that parses a string to an integer. What will be printed?
Java
public class Main {
    public static void main(String[] args) {
        String input = "123";
        int number = Integer.parseInt(input);
        System.out.println(number);
    }
}
A123
BNumberFormatException
C0
Dnull
Attempts:
2 left
💻 code output
intermediate
2:00remaining
What happens when parsing a non-numeric string?
What will be the output or result of running this Java code?
Java
public class Main {
    public static void main(String[] args) {
        String input = "abc";
        int number = Integer.parseInt(input);
        System.out.println(number);
    }
}
A0
Babc
Cnull
DNumberFormatException
Attempts:
2 left
💻 code output
advanced
2:00remaining
Parsing a floating-point string with Integer.parseInt
What will happen when this code runs?
Java
public class Main {
    public static void main(String[] args) {
        String input = "12.34";
        int number = Integer.parseInt(input);
        System.out.println(number);
    }
}
A12.34
B12
CNumberFormatException
D0
Attempts:
2 left
💻 code output
advanced
2:00remaining
Parsing a floating-point string with Double.parseDouble
What will be the output of this Java code?
Java
public class Main {
    public static void main(String[] args) {
        String input = "12.34";
        double number = Double.parseDouble(input);
        System.out.println(number);
    }
}
ANumberFormatException
B12.34
C12
D0.0
Attempts:
2 left
🧠 conceptual
expert
2:00remaining
What is the value of 'result' after parsing with radix 16?
Given the code below, what is the value of the variable 'result' after execution?
Java
public class Main {
    public static void main(String[] args) {
        String hex = "1A";
        int result = Integer.parseInt(hex, 16);
        System.out.println(result);
    }
}
A26
B1A
C16
DNumberFormatException
Attempts:
2 left