Question 18:
Answer given does not match the ouput i get when i execute:
StringBuilder b1= new StringBuilder("snorkler");
StringBuilder b2= new StringBuilder("yoodler")
b1.append(b2.substring(2,5).toUpperCase());
b2.insert(3,b1.append("a"));
b1.replace(3,4,b2.substring(4)).append(b2.append(false));
Given Answer:
b1 b2
snorklerODL yoodler
snorklera yoosnorkleradler
snolerkleryoodlerfalse yoodlerfalse
My Output:
snorklerODL yoodler
snorklerODLa yoosnorklerODLadler
snonorklerODLadlerklerODLayoosnorklerODLadlerfalse yoosnorklerODLadlerfalse
Please let me know if i am correct.
Thanks
(Paul - Update the subject to include questionid)
About Question Id com.enthuware.ets.scjp.v6.2.103 : API Contents
Moderator: admin
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: API Contents
Hello,
The given answer is correct. You need to execute the three statements independent of each other as the question suggests.
HTH,
Paul.
The given answer is correct. You need to execute the three statements independent of each other as the question suggests.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Re: About Question Id com.enthuware.ets.scjp.v6.2.103 : API Contents
Paul,
I didn't understand the purpose of 4 in replace() of the following line
b1.replace(3,4,b2.substring(4)).append(b2.append(false));
replace method takes two arguments but here we have 3 args.... the output is fine if 4 is not there.... can u explain me?
I didn't understand the purpose of 4 in replace() of the following line
b1.replace(3,4,b2.substring(4)).append(b2.append(false));
replace method takes two arguments but here we have 3 args.... the output is fine if 4 is not there.... can u explain me?
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question Id com.enthuware.ets.scjp.v6.2.103 : API Contents
Replace method takes 3 (and not 2) arguments:
Paul.
HTH,StringBuilder replace(int start, int end, String str)
Replaces the characters in a substring of this sequence with characters in the specified String. The substring begins at the specified start and extends to the character at index end - 1 or to the end of the sequence if no such character exists. First the characters in the substring are removed and then the specified String is inserted at start. (This sequence will be lengthened to accommodate the specified String if necessary.)
Paul.
If you like our products and services, please help us by posting your review here.
Re: About Question Id com.enthuware.ets.scjp.v6.2.103 : API Contents
Thanks Paul!!
Do we have to study Java docs for all the string functions?
Do we have to study Java docs for all the string functions?
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question Id com.enthuware.ets.scjp.v6.2.103 : API Contents
Not all but if you just go through the ones that are included in the question of JQ+, you should be good.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 31 guests