How do we trace down this particular example to get to know the number of objects available for GC???
I am having problem with how to draw the sketch of the objects as its not specified in books.. can someone help.. i got an exam on tuesday
well this code should give the compiler error because I compiled and checked
that is because in the constructor of the class we are passing the Drag object that takes the Object as parameter
that should be
well I did this and will try for GC issue now
as I am not sure whether I will be able to solve it to the perfection or not so I am not posting here
I am trying it now
Anikit sir got the answer
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
we don't need to understand Hindi
Hailing Sanath Jaysuriya and Sachin Tendulkar can make our communications better
Hope Devaka sir are interested in Cricket
well is the word "hail" right
I mean to say praising Sachin and Jaysuriya will make our communications better
d2.d and d1.d.d are now pointing to the same object isn't it?
thus cancelling the link between object poited by d2 and object number 2
now 2 was referring to object referred by 1 but as 2 has no external reference
1 also does not have any reference
hence the object 1, 2 are eligible for GC and 3 was done already
hope this helps now
Akila is there a specific line that's confusing you or the whole question??
Joined: Jun 08, 2009
I am not able to understand the whole question. While giving the exams I always get this kind of questions wrong. Sorry, you must have explained many times about this in this forum. This is what I inferred from the diagram
a. When you say d1 --> V, d2 ---> V you are referring to the instance variables
b. At line 7 it creates three new objects out of which one is passed null.
c. I am not understand the line 8
d. At line 9 again 3 objects gets created out of which the third one is passed with the reference d1.
e. At line 10 d2 is referring to d1.
I am not able to connect all these and find out how many objects are eligible for GC.
Akila Agandeswaran wrote:a. When you say d1 --> V, d2 ---> V you are referring to the instance variables
Well actually that V in my diagrams is supposed to mean an arrow. So when I draw this
It means that a is a reference variable. The | and V is the arrow (just like you drew ---> ). The box is the actual object to which the reference variable a points. I've drawn these types of diagrams so many times that I assume that everyone understands them. Anyways I hope you can understand the diagram better now.
Akila Agandeswaran wrote:b. At line 7 it creates three new objects out of which one is passed null.
Akila Agandeswaran wrote:c. I am not understand the line 8
Martin's diagram shows line 8 very well.
Akila Agandeswaran wrote:d. At line 9 again 3 objects gets created out of which the third one is passed with the reference d1.
Akila Agandeswaran wrote:e. At line 10 d2 is referring to d1.
No. Read it carefully. The line is d2.d = d1.d and not d2 = d1...
[Edit: beaten to the V thing]
Joined: Jun 08, 2009
Sorry for mistaking the downward arrow as V. Thanks for your response
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com