I had an exam where I should look at this code and answer the following question.
Object a,b,c,d,e; e= new Object(); b=a=e; e= new Object();How many objects are created by this code ?
The possible answers were these ones:
- 2
- 5
- 4
- Invalid code
It looks like 2 was the right answe, but I don’t understand why – I see 5 objects (a, b, c, d, e) here, don’t I?
Two objects will be instantiated