Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
Forum:
Programmer Certification (OCPJP)
no. of objects created ?
Anonymous
Ranch Hand
Posts: 18944
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
Can anyone please tell me how many objects are created in the following lines and why ? :
StringBuffer sb = new StringBuffer("abcde");
StringBuffer sb1=sb;
thanks,
Siddharth.
Anon Ning
Greenhorn
Posts: 19
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I think there are two objects were created. One is sb and another is "abcde".Am I right?
Anonymous
Ranch Hand
Posts: 18944
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thats what RHE says in one of it's tests. I was unsure about it but now I am sure thats what happens.
thanks a lot.
Siddharth.
kapil apshankar
Ranch Hand
Posts: 66
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Yes,
I too think that two objects will be created.
------------------
Hope this helps. Correct me if I am wrong.
Cheers
,
Kapil
Hope this helps. Correct me if I am wrong.<p>Cheers <img src="smile.gif" border="0"> ,<br />Kapil
Wong KK
Ranch Hand
Posts: 52
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
As you say, then
String
s = "123" + "456";
there's 3 object created??
After some pecan pie, you might want to cleanse your palatte with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
RHE Qs
garbage collector example
Doubt in exercise 9-2,K&B -Threads
Problem with String and StringXxx objects
How many Object is created?
More...