Welcome Guest | Sign in | Register
File - Discussion Page For Q.2715 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > File > Questions and Answers

Q: What will be the result of compiling and run the following code:

public class Test {
public static void main(String... args) throws Exception {
Integer i = 34;
long l = 34l;
if(i.equals(l)){
System.out.println(true);
}else{
System.out.println(false);
}
}
}
A. true B. false
C. Compile error D. None of the above

Answer and Explanation

Answer:false

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

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved 2012-2015 SoftLucent.