Examveda
Examveda

What will be the result of compiling and running the following code:
public class Test{
      public static void main(String... args) throws Exception{
            Integer i = 34;
            int l = 34;
            if(i.equals(l)){
                  System.out.println("true");
            }else{
                  System.out.println("false");
            }
      }
}

A. true

B. false

C. Compiler error

D. None of these

Answer: Option A

Solution(By Examveda Team)

Equals() method for the integer wrappers will only return true if the two primitive types and the two values are equal.


This Question Belongs to Java Program >> Flow Control

Join The Discussion

Related Questions on Flow Control