GeeCON Prague 2014*
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


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
Author

you cannot call append() on String objects

kay lin
Ranch Hand

Joined: May 20, 2004
Posts: 132
Hi:
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 String..you could do that with a StringBuffer....

please let me know.

Many thanks..
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Sounds like a compilation error


[My Blog]
All roads lead to JavaRanch
marc weber
Sheriff

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
sscce.org
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.


True...


SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!
 
GeeCON Prague 2014
 
subject: you cannot call append() on String objects