Consider the following piece of code and select the correct statements. 1. Object o = new String("abcd"); 2. String s = o; 3. System.out.println(s); 4. System.out.println(o); a. The following is displayed: abcd abcd b.The code fails to compile at line 1. c. The code fails to compile at line 2. d. The code fails to compile at line 4. e. The code can be made to compile by changing line 1 to the following: String o = new String("abcd"); Ans given is c. But to me it looks like 'e' also correct. I tried by the changing the code and it worked fine. Anybody is there to agree with me?? This question I took from Jxam.
Surya, Both (c) and (e) are right answers here. However, if you have to choose just one answer, choose the one which is most appropriate ie., (e). On the otherhand, if the question says "select all the right answers" then IMO you should select both (c) and (e). This question should remind you that, in the actual test you should read all the answers given before choosing one. Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Hi Ajith and Masham, Thanks for your replies. It is a muliple choice question and I choose c and e but the answer given is only c. I am an unregistered user so will not be able to open this thread in Mock exam errata. Once again thanks, Surya K