hello
Read this piece of code carefully
if("
String ".trim() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
Answers
a)the code will compile an print "Equal".
b)the code will compile an print "Not Equal".
c)the code will cause a compiler error
This is from abhilash paper.
Why the answer is Not Equals. Although after trim() both strig will be same address.
2)
Read the code below. Will be the result of attempting to compile and run the code below.
public class AQuestion
{
public void method(Object o)
{
System.out.println("Object Verion");
}
public void method(String s)
{
System.out.println("String Version");
}
public static void main(String args[])
{
AQuestion question = new AQuestion();
question.method(null);
}
}
Answers
1)The code does not compile.
2)The code compiles cleanly and shows "Object Version".
3)The code compiles cleanly and shows "String Version"
4)The code throws an Exception at Runtime.
Can some guru help?
[This message has been edited by parag bharambe (edited November 16, 2000).]