Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Garbage Collection

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
lowercase baba
Posts: 13050
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know that 'c' is correct either. the OBJECT doesn't allocate memory, the JVM does.
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
fred rosenberger
lowercase baba
Posts: 13050
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 13050
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Point taken.
My apologies to anyone who thought I went over the line.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic