Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MindQ's 37 mock

 
prasanna perera
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All!
37. Which of the following statements about Java's garbage collection are true?
a) The garbage collector can be invoked explicitly using a Runtime object.
b) The finalize method is always called before an object is garbage collected.
c) Any class that includes a finalize method should invoke its superclass' finalize method.
d) Garbage collection behavior is very predictable.
I know that d is wrong. What about the rest ?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by prasanna perera:
Hi All!
37. Which of the following statements about Java's garbage collection are true?
a) The garbage collector can be invoked explicitly using a Runtime object.
b) The finalize method is always called before an object is garbage collected.
c) Any class that includes a finalize method should invoke its superclass' finalize method.
d) Garbage collection behavior is very predictable.
I know that d is wrong. What about the rest ?

-------------------------------
a> true
the programmer can request to run the GC thread.
but the thread would run and garbage collect is highly unpredictable.
b>true
The finalize method is always called before an object is garbage collected. thus the finalize method is called only by the GC.the programmer cannot call the method
c> not sure
someone please guide me.
Any class that includes a finalize method should invoke its superclass' finalize method.
i think this is true since before any object is to be Gc, the super class object should also be Gc'ed.
i remember that super class constructor is called prior to the invoked class constructor. this means that when the derived class object is to be Gc'ed the base class object should be destroyed first.
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C is true also. If you have your own finalize method that cleans up things before they get GC, you want to call Object's finalize method to destroy the object after you did the part you wanted to do.
As for A, I think that is false, unless I am missing the meaning of invoked (which I may be). You can call the method explicitly System.GC(); but that doesn't mean the method will be invoked as it is unpredictable as to when the method will run. I have seen A worded a few different ways and it usually is false because of the unpreditable nature of GC. Anyone's thoughts?
 
chetan nain
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

finally
1. false
2. true
3. false
4. false
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if I understand you post chetan, but finally is different than finalize. I think the answer is:
A. False
B. True
C. True
D. False
B and D I am postive about, C I feel pretty confident, and A I am uncertain.
 
Ira Jain
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Bill's answers .About A ,I think the answer should be false as just by calling the System.gc() we cannot be 100%sure that the garbage collector will be called at that particular moment.
 
Mukesh Rathod
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
regarding option 1.
Thw API syas about gc:
Runs the garbage collector.
Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects.
The call System.gc() is effectively equivalent to the call:
Runtime.getRuntime().gc()

So It seems that choice 1 is correct one.
 
Shan Karawita
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Prasanna,

This is not a reply to your problem.Sorry about that.
It seems you're a Sri Lankan.Are You ? If you are a Sri Lankan pl tell me when are you going to sit for the Test & How did you buy the Voucher & what is the cost of it.If you have bought the voucher from where did you buy it..

here is my email address...

dushan@jkcs.slt.lk
Thankx,
Shan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic