Hi,
Assuming x does not refer to anything before this statement...
String x = "first" + "second";
...how many objects are created?
I have seen two explanations:
1) Answer three: One that x refers to, i.e. "firstsecond". One as a result of "first", which nothing refers to and One as a result of "second" that nothing refers to.
2) Answer one: One that x refers to, i.e. "firstsecond". That is all, since "first" and "second" are string literals and NOT objects.
I'd appreciate a clarification for my upcoming exam.
On your marks...get set...go!
Cheers,
Simon.