Skip to content
Veltoryx Technologies
ProLesson 14.6Intermediate3 min readUpdated 30 October 2026

Tricky output questions

Predict the output of short Java snippets that interviewers use to test your fundamentals. Every answer below was produced by actually running the code.

"What does this print?" questions test whether you really understand the rules, not just the syntax. Cover the output, decide your answer, then read the explanation. Every output on this page comes from running the code.

011. String concatenation order

Puzzle1.java
public class Puzzle1 {
    public static void main(String[] args) {
        System.out.println(1 + 2 + "3" + 4 + 5);
    }
}
Expected output
3345

Left to right: 1 + 2 = 3 (numbers), then 3 + "3" = "33" (a String), then "33" + 4 + 5 = "3345".

Loading the rest of the lesson…