This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
String s1 = "ABCDEF"; String s2 = s1.substring(0, 3); String s3 = s1.substring(3, 6); String s4 = s2.toUpperCase() + s3.toLowerCase(); How many String objects creates this code? A. 4 B. 5 C. 6 D. StringIndexOutOfBoundsException is thrown I think ans is 4.Please correct me if i m rong. Thanks.
sunilkumar ssuparasmul
Ranch Hand
Joined: Dec 13, 2000
Posts: 142
posted
0
String s1 = "ABCDEF"; String s2 = s1.substring(0, 3); String s3 = s1.substring(3, 6); String s4 = s2.toUpperCase() + s3.toLowerCase(); How many String objects creates this code?
i guess 5 objects bcos s1,s2,s3,s4 are all obvious but s3.toLowerCase returns a new object "def" . so on the whole 5 objects r created . correct me if i am wrong.
------------------ "Winners don't do different things They do things differently"
"Winners don't do different things<br /> They do things differently"