539). Which of these methods of Boolean wrapper returns boolean equivalent of an object.
[A]getBool()
[B] booleanValue()
[C] getbooleanValue()
[D]getboolValue()
Show Answer
Correct Answer: booleanValue()
Notes:
Answer: b
Explanation: None.
540). Which of the following constant are defined in Boolean wrapper?
[A]TRUE
[B]FALSE
[C]TYPE
[D]All of the mentioned
Show Answer
Correct Answer: All of the mentioned
Notes:
Answer: d
Explanation: Boolean wrapper defines 3 constants – TRUE, FALSE & TYPE.
541). Which of these methods return string equivalent of Boolean object? a) getString()
[A]getString()
[B]toString()
[C]converString()
[D]getStringObject()
Show Answer
Correct Answer: toString()
Notes:
Answer: b
Explanation: None.
542). Which of these methods is used to know whether a string contains “true”?
[A]valueOf()
[B]valueOfString()
[C]getString()
[D]none of the mentioned
Show Answer
Correct Answer: valueOf()
Notes:
Answer: a
Explanation: valueOf() returns true if the specified string contains “true” in lower or uppercase and false otherwise.
543). Which of these class have only one field?
[A]Character
[B] Boolean
[C]Byte
[D]void
Show Answer
Correct Answer: void
Notes:
Answer: d
Explanation: Void class has only one field – TYPE, which holds a reference to the Class object for type void. We do not create an instance of this class.
544). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
String str = "true";
boolean x = Boolean.valueOf(str);
System.out.print(x);
}
}
[A]True
[B]False
[C]Compilation Error
[D] Runtime Error
Show Answer
Correct Answer: True
Notes:
Answer: a
Explanation: valueOf() returns true if the specified string contains “true” in lower or uppercase and false otherwise.
Output:$ javac Output.java
$ java Output
true
545). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
String str = "true false true";
boolean x = Boolean.valueOf(str);
System.out.print(x);
}
}
[A]True
[B]False
[C]Compilation Error
[D]Runtime Error
Show Answer
Correct Answer: False
Notes:
Answer: b
Explanation: valueOf() returns true if the specified string contains “true” in lower or uppercase and false otherwise.
Output:
$ javac Output.java
$ java Output
false
546). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
String str = "TRUE";
boolean x = Boolean.valueOf(str);
System.out.print(x);
}
}
[A]True
[B]False
[C] Compilation Error
[D]Runtime Error
Show Answer
Correct Answer: True
Notes:
Answer: a
Explanation: valueOf() returns a Boolean instance representing the specified boolean value. If the specified boolean value is true, this method returns Boolean.TRUE; if it is false, this method returns Boolean.FALSE. If a new Boolean instance is not required, this method should generally be used in preference to the constructor Boolean(boolean), as this method is likely to yield significantly better space and time.
Output:
$ javac Output.java
$ java Output
true
547). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
String str = "true false";
boolean x = Boolean.parseBoolean(str);
System.out.print(x);
}
}
[A]True
[B]False
[C]System Dependent
[D]Compilation Error
Show Answer
Correct Answer: False
Notes:
Answer: b
Explanation: parseBoolean() Parses the string argument as a boolean. The boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string “true”.
Example: Boolean.parseBoolean(“True”) returns true.
Example: Boolean.parseBoolean(“yes”) returns false.
Output:
$ javac Output.java
$ java Output
false
548). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
String x = Boolean.toString(false);
}
}
[A]True
[B]False
[C]System Dependent
[D]Compilation Error
Show Answer
Correct Answer: False
Notes:
Answer: b
Explanation: toString() Returns a String object representing the specified boolean. If the specified boolean is true, then the string “true” will be returned, otherwise the string “false” will be returned.
Output:
$ javac Output.java
$ java Output
false