Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes you cannot call append() on String objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "you cannot call append() on String objects" Watch "you cannot call append() on String objects" New topic

you cannot call append() on String objects

kay lin
Ranch Hand

Joined: May 20, 2004
Posts: 132
I was just doing some of the practice exam for SCJP 1.4
i came across a string related question

and it asks you what the result is..

I think the compilation would fail, wouldnt it. Since d is a String object, and i don't think you can call append() on could do that with a StringBuffer....

please let me know.

Many thanks..
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Sounds like a compilation error

[My Blog]
All roads lead to JavaRanch
marc weber

Joined: Aug 31, 2004
Posts: 11343

If you're preparing for the exam, my advice is to write lots of code to test and verify your understanding. That way, you get the practice, immediate feedback, and reinforcement.

(Besides, you could probably test this in less time than it took to post. )

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
A 30 second check of the String API would hurt you.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Aniket Patil
Ranch Hand

Joined: May 02, 2006
Posts: 218
A 30 second check of the String API ~wouldn't~ hurt you.


SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!
I agree. Here's the link:
subject: you cannot call append() on String objects
It's not a secret anymore!