Skip to content
Sharp

Core Java · interview question

What will be the result of the following code?

Multiple choiceEasychapter-1-curatedpremiumcore-javacode-reading-and-debugging
java
int price = 100;
boolean result = (price > 50) || (price < 30);
System.out.println(result);
Choose one answer
Answer and explanation

Correct answer

A. True

Why

The result is true because the logical OR operation only requires one true condition, and 'price > 50' is true.

Test yourself on Core Java

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

Start free test
All Core Java questions →