Fiona
be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Stephen Davies wrote:Is it not that when you say StringBuffer s2 = s3, creating a StringBuffer at compile time which points to the value "abc"?
All code in my posts, unless a source is explicitly mentioned, is my own.
be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Stephen Davies wrote:Ok, point duly taken. However is the given answer of 3 objects incorrect, should there only should be two?
- Admittedly, two was my guess, I was trying to see if there would be a possible reason for 3 objects.
All code in my posts, unless a source is explicitly mentioned, is my own.
How many objects are created ?
be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Stephen Davies wrote:I won't worry about Strings and GC for the exam, I promise.
However, the actual question asked is:
How many objects are created ?
So I cannot see whether they are compile-time or run-time created, so here surely there are only two objects created at line 1. and 3.?
All code in my posts, unless a source is explicitly mentioned, is my own.
be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Stephen Davies wrote:Ruben, ahhhh! now I get it , doh, I guess I gotta brush up more on my Strings"
Thanks for that
All code in my posts, unless a source is explicitly mentioned, is my own.
SCJP5 and SCWCD1.5
Think Twice Act Wise...
SCJP 5
Only two objects are created
Regards
Sunny Mattas
SCJP5
Skool. Stay in. Smartness. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|