Skip to content
Sharp

Core Java · interview question

What is the result of the following expression? int price = 50; boolean isEligibleForDiscount = price < 100 && price!= 0;?

Multiple choiceMediumchapter-1-curatedpremiumcore-javaoperators-and-expressions
java
int price = 50;
boolean isEligibleForDiscount = price < 100 && price != 0;
Choose one answer
Answer and explanation

Correct answer

A. True

Why

The expression evaluates to true because 'price' is less than 100 and not equal to 0, satisfying both conditions of the '&&' operator.

Test yourself on Core Java

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

Start free test
All Core Java questions →