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