Oracle Certified Associate Java Se 8 Programmer · Free Practice Question Medium

Question 20

Given code: 

What is the result?

  • A

    false:false:false:null

  • B

    true:false:false:null

  • C

    false:false:true:null

  • D

    Compilation error

Reveal correct answer

Correct answer: B

Explanation

Boolean class code uses equalsIgnoreCase method to validate the passed String, so if passed String is "true" ('t', 'r', 'u' and 'e' can be in any case), then boolean value stored in Boolean object is true otherwise false.


b1 stores true, b2 stores false, b3 stores false and as b4 is of reference type, hence it can store null as well.

Output is: true:false:false:null

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need