This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage Collection" Watch "Garbage Collection" New topic
Author

Garbage Collection

Vineela Devi
Ranch Hand

Joined: Dec 20, 2003
Posts: 191
Hi,
I came acroos this q in one of the mock exams and the answer is given as A and C.
But, i think the answer is only C.
Anyone pls explain.

Thanks in Advance
Vineela
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You'll have to check the language specifications, if indeed this really is a language issue. I'm not sure where JVM operation is mandated. However, choice A is poorly-worded to begin with. I would agree that C is the only answer.
You can't really depend on the JVM doing anything at a precise time when it comes to garbage collection. What constitutes "low memory"? Who knows. A JVM could just as easily let all the memory run out before doing its garbage collection. It could just as easily have it always running so there never is a "low memory" issue. Beats me.
If this was an actual exam. My answer: C. (Unless it said "choose 2 answers.") Bad question.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
Hi Vineela
I would say only answer C is correct. GC may be implemented differently by different compilers.
[ March 30, 2004: Message edited by: Anupam Sinha ]
Kirtikumar Puthran
Ranch Hand

Joined: Mar 04, 2003
Posts: 37
Hi,
Actually, garbage collector runs as a low-priority thread. So I would also go for the option C. However I do agree with Anupam that "GC may be implemented differently by different compilers".


Regards,<br />Kirti
Saravana Balasubramanian
Greenhorn

Joined: Mar 30, 2004
Posts: 3
Hai friends,
I agree with the answers both A and C. b'coz Garbage Collection thread is always running as a low priority thread. so, whenever the memory problem arises, the JVM makes the GC thread as a high priority thread. It is up to the JVM, to find the memory problem and call the GC thread.
Hope I am correct.
:roll:
chary vangeepuram
Greenhorn

Joined: Sep 16, 2002
Posts: 7
Hi,
-----------------------------------------------------------
GC may be implemented differently by different compilers.
-----------------------------------------------------------
Is n't GC implemented in JVM rather than compiler ?
I thought GC is a run-time issue...
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11352
    
  16

I don't know that 'c' is correct either. the OBJECT doesn't allocate memory, the JVM does.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by fred rosenberger:
I don't know that 'c' is correct either. the OBJECT doesn't allocate memory, the JVM does.

Splitting hairs, there, Fred. It should probably read "memory allocated for the object" rather than "by the object." Regardless, I think it's safe to say that C is a correct answer.
It's difficult to say that A is a correct answer because you never really know for sure what the JVM is going to do with garbage collection. In theory, the garbage collection thread should run when you get low on memory, but you don't know for certain that it will.
Corey


SCJP Tipline, etc.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11352
    
  16

Isn't the whole point of this exam to split hairs? I'm not trying to be an a** or anything, but the statement is wrong. As soon as you start saying "well, they MEANT this when they wrote THAT", you might as well throw out the whole test.
but of the above choices, i would proabably pick C, if i am forced to pick anything.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by fred rosenberger:
Isn't the whole point of this exam to split hairs?

It is, but you must remember that, unlike the folks at Sun that ponder over every last word in the question (and are paid to do so), most folks that come up with mock exams don't do so. Therefore, sometimes you just have to take mock exam questions with a grain of salt.
If this were an actual question from the Sun exam, I'd definitely split hairs with the best of 'em. However, sometimes I find it best to keep in mind the source of the question. Whoever wrote this was probably trying to help others get certified - anyone that does that means well, but doesn't always get it perfect.
Corey
[ March 30, 2004: Message edited by: Corey McGlone ]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11352
    
  16

Point taken.
My apologies to anyone who thought I went over the line.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by fred rosenberger:
My apologies to anyone who thought I went over the line.

I don't think any apologies are required, Fred. It's just that I've been around for a while and, if you spend your times splitting hairs over mock exams, you're quickly going to go bald.
That said, there are still times at which I think it's good to split hairs. :roll: For example, if this had been spotted in a well-known SCJP prep book (M&R or K&B, for example), I'd certainly take up the point of splitting hairs.
Corey
 
GeeCON Prague 2014
 
subject: Garbage Collection