This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
What is the output (Assuming written inside main) String s1 = new String("amit"); System.out.println(s1.replace('m','r')); System.out.println(s1); String s3="arit"; String s4="arit"; String s2 = s1.replace('m','r'); System.out.println(s2==s3); System.out.println(s3==s4); a) arit amit false true b) arit arit false true c) amit amit false true d) arit amit true true Should it not be d)
no it is a) try by replacing == with equals and get the idea
Joined: Nov 08, 2000
I got the thing I suppose. Whenever you perform any method of the String class on a string, a altogether new String is created and it has nothing to do with a string existing in the string pool. So it gives false.. Thanks. sachin.