Skip to content
Sharp

Core Java · interview question

Given this code if 'cartTotal' is 75 and 'loyaltyMember' is false, what outcome should you expect?

Multiple choiceHardchapter-1-curatedpremiumcore-javaconditions-and-branching
java
if (loyaltyMember) { applyDiscount(); }
if (cartTotal > 50) { applyFreeShipping(); }
Choose one answer
Answer and explanation

Correct answer

C. Only free shipping

Why

Since 'loyaltyMember' is false, no discount is applied. However, if free shipping is given for totals over 50, 'cartTotal' of 75 qualifies for free shipping alone.

Test yourself on Core Java

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

Start free test
All Core Java questions →