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

Home > Java Programming > Inner Classes > 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 {
Object o = new Object() {
public boolean equals(Object obj) {
return true;
}
}
System.out.println(o.equals("test"));
}
}
A. Compile Fail: semicolon missing at Object o = new Object() { public boolean
equals(Object obj) { return true; } };
B. test
C. Compilation succeed but Runtime Exception D. None of the above

Answer and Explanation

Answer:Compile Fail: semicolon missing at Object o = new Object() { public boolean
equals(Object obj) { return true; } };

Explanation:
semicolon missing at Object o = new Object() { public boolean equals(Object obj)
{ return true; } };

Comment on this Question

Name:

Loading...




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