Skip to content
Sharp

Core Java · interview question

How do you check if a non-premium customer should receive a loyalty discount using an if-else statement?

Multiple choiceMediumchapter-1-curatedpremiumcore-javaconditions-and-branching
java
boolean isPremium = false;
if (!isPremium) { applyLoyaltyDiscount(); }
Choose one answer
Answer and explanation

Correct answer

D. If (!isPremium) { applyLoyaltyDiscount(); }

Why

The logical negation operator '!' can be used to check if a boolean condition is false. This makes the condition more concise and readable than explicitly comparing with false.

Test yourself on Core Java

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

Start free test
All Core Java questions →