• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Questions from MindQ exam

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are a couple of questions that I am confused about..
1) How many objects are eligible for garbage collection once execution has reached the line labeled Line A?
String name;
String newName = "Nick";
newName = "Jason";
name = "Frieda";
String newestName = name;
name = null;
//Line A
My answer was 0 because all String references are referring to string literals and there is no String object created with new operator. The references are just made to point to different string literals. String literals are not Garbage Collected, Right?
The answer given was 1, presumably I think they are referring to String "Nick" that was originally referred to by var newName.
This was short answer question
2)If you want subclasses to access, but not to override a superclass member method, what keyword should precede the name of the superclass method?
Since they emphasized on the fact that subclasses (that is from any package) must be able to access the method I wrote the answer as public final as the keyword
But the answer given was only final as the keyword.
If such a question comes in the real exam (which I hope would not be asked) what should we shoot for?
Thanks for the help!
Amol
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amol,
1. You're right, string literals are not gc'd. Unfortunately most of the mock exams ignore this so when you see a gc question on a mock that uses string literals, just assume they are gc'd and go from there.
2. They are only asking 'what keyword' not keywords. The 'final' keyword, if used on a method, prevents overriding. You will have to read exam questions carefully. They don't deliberately try to trick you, they are fairly precise in their wording.
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'm sorry.. but I do not quite get the emphasis on the 2nd question. Is it a question about being able to access? or a question about not being able to override?
And, if it's only one keyword, which should we choose? public or final?
Does the real SCJP exam provide us the objectives for each question asked?
- eric
 
Amol Keskar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks Jane,
For the 2nd question, I had pretty much similar concern to what Eric has mentioned.
I am not sure if we should write only final or write both public final
Amol
 
reply
    Bookmark Topic Watch Topic
  • New Topic