This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
The answer to the first Question is correct !! The answer to 2a) is it returns true as there is only one reference at sb1 !! The answer to 2b) is also true as it is the same stringbuffer object Praveen
Joined: Dec 14, 2002
Thanks. Q.StringBuffer sb1=new StringBuffer("abc"); StringBuffer sb2=new StringBuffer("abc"); What does this return? if(sb1==sb2) Q.String s1=new String("abc"); String s2=s1; what does the following comparisons return? A.if(s1==s2) B.if(s1.equals(s2)) please give me the answer.Thanks in advance.
The answer to the first one is false because sb1 and sb2 are two different references. s1 == s2 is true since both refer to the same reference. s1.equals(s2) is true because if the two string references are same then this has to be true.