Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


For an expression 'a?b:c', what must 'a' be?

  1. An integer

  2. A floating point number

  3. A boolean

  4. Any object

The correct answer is: A boolean

'a' must be a boolean for the ternary operator to work properly. If 'a' is not a boolean, it will be evaluated as a truthy or falsy value and the wrong option (either b or c) will be returned. Option A and B are incorrect because they are data types that are not boolean. Option D is incorrect because any object will also be evaluated as a truthy or falsy value and the wrong option may be returned.