LearnFrenzy
Sign in Take a free test

Object Class and Wrapper Classes · Predict the Output · Question 11

Parsing booleans and characters Answer, explanation & discussion

  • Output
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 11 Back to Exercise

What is the output of the following Java program?

Main.java
public class Main {
    public static void main(String[] args) {
        System.out.println(Boolean.parseBoolean("True") + " " + Boolean.parseBoolean("yes") + " " + Boolean.parseBoolean(null) + " " + Character.isDigit('٣') + " " + Character.getNumericValue('Z') + " " + Character.toChars(66)[0]);
    }
}
  • A true false false true 35 B Correct
  • B true true false false 35 B
  • C false false false false -1 B
  • D true false NullPointerException
Correct Answer: Option A

Only "true" (any case) parses to true; null gives false. isDigit accepts Unicode digits such as Arabic-Indic ٣. getNumericValue treats letters as base-36 digits: Z = 35.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links