|
Hi All,
I was asked this question by an interview in Amazon.I am not sure if the one I know is the righht answer.You have the following code.
code:// C is a class
C c1 = new C;
C c2 = c1;
Can you tell me what happens when this code is executed,in terms of memory and all.I spoke about copy constructor and screwed myself.
Thanks,
pandu
|
|
|
C c1=new call();
C c2;
c1--> creates memory for the object c1;
U need to clear the garbage when ever its usage over.
c2--> Just it is a reference to the class.
no need for clearing garbage collection.
|
|
|
|
|
|
|
|