Skip to content
Sharp

Core Java · interview question

Consider the expression: int result = 3 + 5 * 2 - 8 / 4 % 3. What is the value of 'result'?

Multiple choiceHardchapter-1-curatedpremiumcore-javaoperators-and-expressions
java
int result = 3 + 5 * 2 - 8 / 4 % 3;
Choose one answer
Answer and explanation

Correct answer

A. 13

Why

Following operator precedence: multiplication and division/modulus are evaluated before addition/subtraction. Calculate as follows: 5 * 2 = 10, 8 / 4 = 2, 2 % 3 = 2, then 3 + 10 - 2 = 11.

Test yourself on Core Java

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

Start free test
All Core Java questions →