posted 20 years ago
Um, well not to be a pain, but unless you're being very specific about your useage of the term "object" there are going to be 2 strings created.
The first will be "hello world" string placed in the constant string pool. After that, the toUpperCase method will return a separate string since strings are immutable.
So, 2 strings. Um, how many objects? Well, is a string placed in the constant memory pool an object? You did call toUpperCase on it, so I would venture to say that it is an object.
Of course, I didn't run across any questions on the exam that asked how many "string objects" are created by a segment of code. Only questions that just asked "how many strings".
Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED