Vidyalelo
Java Programming · Q44

Flow Control

Programming · Java Programming · question 44

Q44

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
Answer
B.
false
C.
Compiler error
D.
None of these

Answer: Option A

Solution

Answer: Option A
Solution:

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