Skip to content
Sharp

Core Java · interview question

If 'boolean onSale = false; int quantity = 10;', what does the expression 'onSale || quantity > 5' evaluate to?

Multiple choiceEasychapter-1-curatedpremiumcore-javaoperators-and-expressions
Choose one answer
Answer and explanation

Correct answer

C. True

Why

The '||' operator is a logical OR, meaning the expression is true if at least one condition is true. Here, 'quantity > 5' is true, so the whole expression evaluates to true.

Test yourself on Core Java

A free test with instant, explained results. No account needed.

Start free test
All Core Java questions →