What will be the output of the following code:

public static void main(String[] args) {
    int i = 10;
    Integer x = new Integer(10);
    if(x == i) {
        System.out.print("true");
    } else {
        System.out.print("false");
    }
}
Explanation
During the compilation, intValue() will be added to the comparison expression, so it will become x.intValue() == i

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes