John Stark wrote:Is there a difference between objects and instances?
John
Joanne
Joanne Neal wrote:
John Stark wrote:Is there a difference between objects and instances?
John
There might be certain situations where you would use one instead of the other (although I can't think of an example off the top of my head), but in general they are interchangeable.
ket bhav wrote:Did you mean by Inheritance and changing object and instance?
Joanne
ocjp december 2011 -
may peace prevail on earth
Joanne
John Wintermute wrote:I think it might be five String objects, because on the last line, a + b + a1, first there will be a String for "a + b", and then another that adds that String to 'a1'.
What does everyone think?
Astha - OCPJP 6 (90%)
Astha Sharma wrote:
John Wintermute wrote:I think it might be five String objects, because on the last line, a + b + a1, first there will be a String for "a + b", and then another that adds that String to 'a1'.
What does everyone think?
I am not certain about it but if in string a+b+a1, at first object is to be created for a+b then it should not be a new object. Since a+b is already an object in the string pool.
What do you say? Correct me if I am wrong.
Joanne
Joanne Neal wrote:In this case you are wrong. However, if a and b were declared final then that would be true because the compiler would know that a + b would have a fixed value and could treat it as a String literal and add it to the String pool.
Astha - OCPJP 6 (90%)
Joanne
Astha - OCPJP 6 (90%)
Aditya Jha wrote:then you have to think about the StringBuilder objects getting created
Joanne