Skip to content
Sharp

Core Java · interview question

In an e-commerce app, what does the following snippet print if 'isMember' is true?

Multiple choiceEasychapter-1-curatedpremiumcore-javaconditions-and-branching
java
boolean isMember = true;
if (isMember) { System.out.println("Member discount applied"); }
Choose one answer
Answer and explanation

Correct answer

C. "Member discount applied"

Why

The if statement checks the boolean variable 'isMember'. Since it is true, the code inside the if block executes, resulting in the message "Member discount applied" being printed.

Test yourself on Core Java

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

Start free test
All Core Java questions →