Mastering Java: The Ultimate Quiz for 'Thinking in Java

1 / 510

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

An integer

A floating point number

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.

Get further explanation with Examzify DeepDiveBeta

Any object

Next Question
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy