Skip to content
Sharp

Core Java · interview question

What does this minimal total-printing snippet output?

Multiple choiceEasychapter-1-curatedpremiumcore-javacode-reading-and-debugging
java
int total = 10;
System.out.println(total);
Choose one answer
Answer and explanation

Correct answer

B. 10

Why

The variable 'total' is initialized to 10, and no operations are performed on it before it is printed.

Test yourself on Core Java

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

Start free test
All Core Java questions →