Bird
0
0

What does the method Boolean.valueOf(String s) return when the input string is "true" (case insensitive)?

easy📝 Conceptual Q2 of 15
Java - Wrapper Classes
What does the method Boolean.valueOf(String s) return when the input string is "true" (case insensitive)?
ABoolean object representing true
BPrimitive boolean false
CString "true"
DPrimitive boolean true
Step-by-Step Solution
Solution:
  1. Step 1: Understand Boolean.valueOf(String s) behavior

    This method returns a Boolean object, not a primitive boolean.
  2. Step 2: Check input "true" case

    For input "true" (case insensitive), it returns Boolean.TRUE object.
  3. Final Answer:

    Boolean object representing true -> Option A
  4. Quick Check:

    Boolean.valueOf returns Boolean object [OK]
Quick Trick: Boolean.valueOf returns object, not primitive [OK]
Common Mistakes:
  • Assuming it returns primitive boolean
  • Confusing with parseBoolean method
  • Expecting a String return type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes