What does this print?
System.out.println(1 + 2 + "3");
What this Java test measures, in short
This test checks whether you can predict what real Java code does: how operators and types behave, when two objects count as equal, how the standard collections work and how objects and exceptions behave at run time.
Every snippet compiles and runs on Java 21 or later (imports omitted). The questions are our own and are not standardised against a population, so treat the result as a check on your knowledge, not a certification.
By What's Your IQ · Reviewed 4 Oct 2026- Format
- 15 predict-the-output questions, 4 options each
- Topics
- Operators and types, strings, equality and wrappers, collections, objects and exceptions
- Version
- Java 21+, the long-term-support line most teams now target
- Language
- Designed by James Gosling at Sun Microsystems; first released 1996
== asks "same object?", not "same value?"
For objects, a variable holds a reference. == compares references, so whether two equal strings or Integers are "==" depends on whether Java reused one object. Step through to see when it does.
Modern Java says the same thing in fewer lines
final class Point { private final int x, y; Point(int x, int y) { this.x = x; this.y = y; } int x() { return x; } int y() { return y; } // + equals, hashCode, toString…}record Point(int x, int y) {}A record declares an immutable data carrier in one line. The compiler writes the constructor, accessors, equals, hashCode and toString for you.
- Oracle. Oracle Java SE Support Roadmap.
- Gosling, J., Joy, B., Steele, G., Bracha, G., Buckley, A., Smith, D., & Bierman, G. The Java Language Specification, Java SE 21 Edition. Oracle.
- Pressler, R., & Bateman, A. (2023). JEP 444: Virtual Threads. OpenJDK.