Skip to content
Sharp

Core Java · interview question

Given the code snippet below, what will be the result of the comparison using '=='?

Multiple choiceMediumchapter-7-curatedpremiumcore-javawrapper-types-and-autoboxing
java
Integer a = new Integer(100);
Integer b = new Integer(100);
System.out.println(a == b);
Choose one answer
Answer and explanation

Correct answer

C. False

Why

The '==' operator checks for reference equality when used with objects, not value equality. Integer objects created with 'new' will have different references.

Test yourself on Core Java

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

Start free test
All Core Java questions →