This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Q from http://examsguide.com/ - GC eligible

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From http://examsguide.com/scjp/freequestions2.html:

For the below code, how many objects are eligible for collection after line 6 ?

Answer says 2.
But I can only see 1 object is eligible.
After line 3, c1 points to object1.
After line 4, object1 becomes eligible; both c1,c2 point to new object2.
After line 5, c3 points to object3.
After line 6, c2, c3 point to object3; c1 still points to object2.





after line 6, how many objects are eligible for garbage collection?


Ans: 1

Ans: 2

Ans: 3

Ans: 4

None of the above

Explanation:
No Explanation Available




Also another one from the same page: these may just be badly formated, but the below code seems to create only 2 objects.


14)

1. StringBuffer s1 = new StringBuffer("abc");
2. StringBuffer s2 = s1;
3. StringBuffer s3 = new StringBuffer("abc");
How many objects are created ?


0

Ans: 1

Ans: 2

Ans: 3

Explanation:
No Explanation Available

Ans: 4
[ November 26, 2008: Message edited by: Clay Chow ]
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first question has already been discussed numerous times (search these forums for 'anotherMethod').

The answer to the second question depends on the exact wording of the question - when that particular code is executed only two objects are created (the 2 StringBuffers). However, at the time the class was loaded, a String containing the value "abc" would also have been created.
 
We don't have time to be charming! Quick, read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic