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

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

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

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.