File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes GC Questions are worth for the garbage. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GC Questions are worth for the garbage." Watch "GC Questions are worth for the garbage." New topic
Author

GC Questions are worth for the garbage.

hema janani
Ranch Hand

Joined: May 19, 2000
Posts: 70
I seriously hope Sun changes the ambiguity involved in Threads & GC Questions.
All Q. I feel has yes & no validations
a.you can directly run the GC whenever you want.??--t
b.GC runs in a low memory situation.--f(not always)
c.only the objects whose ref are set to null are GC.--false
d.The finalise method of the subclass has to make a call to the superclass finalise method.(is it a must)
e.The GC informs your object when it is about to be GC.
please be brief.
[This message has been edited by hema janani (edited September 26, 2000).]
Kishan Kumar
Ranch Hand

Joined: Sep 26, 2000
Posts: 130
Janani,
a. You can run GC whenever u want is FALSE i suppose.
You can only request the JVM to put an effort to run
GC. System.gc() is not looked in the sameway as
System.out.println(). The former only puts a request
and JVM may or may not take up your request.
c. Only objects whose ref are set to null are GC - FALSE
since even if a object is out of scope it can be GC'ed.
In case of string Literals even if you set the reference
to null the object is not GC'ed.
d. The finalise method of the subclass has to make a callto the
superclass finalise method - TRUE.
Can anybody please explain clearly this point to me. I have
seen at many places this is true but i have not understood
why.

b,e I am not sure.

------------------
Regards,
V. Kishan Kumar


Regards,<BR>V. Kishan Kumar
Ramesh Donnipadu
Ranch Hand

Joined: Sep 16, 2000
Posts: 100
Kishan,
(d) Finalize method of a subclass need not make a call to super.finalize(). It is a good programming practice to do it. But if you don't do it, compiler won't insert any calls nor will it flag an error.
e). Not always. If the object is being garbage collected for the first time, it calls the finalize() method and that is how the object gets to know that it is being gc'ed. If you resurrect the memory, GC is not going to call finalize() again and you don't know when you are going to be GC'ed.
hema janani
Ranch Hand

Joined: May 19, 2000
Posts: 70
again 2-3 views of same Qs have started
so finally please someone confirm once that in exam if I come across the foll alternatives,all are marked as false.
a.you can directly run the GC whenever you want//false
b.GC runs in a low memory situation.--//false
c.only the objects whose ref are set to null are GC.--//false
d.The finalise method of the subclass has to make a call to the superclass finalise method.//false
e.The GC informs your object when it is about to be GC.//false

Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
I agree with Ramesh. Given the statements as they are, all of them are false.
The option (e) is vaguely worded. The answer can be true or false. One can argue either way, however just don't get confused. I am 100% certain the questions in the actual exam will have definitive answers.
Where did you find this question??
Ajith


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
hema janani
Ranch Hand

Joined: May 19, 2000
Posts: 70

I was desperately awaiting yours or maha's reply.
Thanks a million Ajith
I have collected all the theoritical Qs on GC as well as Thread
from various mock exams.out of which I had doubts on above five Qs.
I am appearing on 29th then I will post the whole database forthe benifit of others on java ranch.
no emails entertained asking for the same.
sorry to be bit rough.
thanks
hema

Originally posted by Ajith Kallambella:
I agree with Ramesh. Given the statements as they are, all of them are false.
The option (e) is vaguely worded. The answer can be true or false. One can argue either way, however just don't get confused. I am 100% certain the questions in the actual exam will have definitive answers.
Where did you find this question??
Ajith

Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Wow!!! that's great. Your database will surely help others and me too-for redirecting other Ranchites
Good luck for your exam.
Ajith
Ramesh Donnipadu
Ranch Hand

Joined: Sep 16, 2000
Posts: 100
Good luck Hema.
Don't forget to let me know how it went and your experiences on what could possibly go wrong in actual test. That will help all.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GC Questions are worth for the garbage.