Sail E0 Webinar
Question


What is the output of this program?


class Output {
public static void main(String args[]) {
String str = "true";
boolean x = Boolean.valueOf(str);
System.out.print(x);
}
}
Options:
A .  true
B .  flase
C .  Compilation Error
D .  Runtime Error
Answer: Option A

valueOf() returns true if the specified string contains "true" in lower or uppercase 

and false otherwise.
Output:
$ javac Output.java
$ java Output
true




Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers