Morten Monrad Pedersen

Ranch Hand
+ Follow
since May 15, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Morten Monrad Pedersen

Hi fellow ranchers

I just took the SCJP test today (got 93% ), and when I went back and wanted to take another look at a drag and drop question, the software warned me that my previous answer would be deleted. It then asked whether I wanted to see the question again or not.
Hi Bert

Thank you for the answer, though it's not the one i wanted to hear .
Hi

K&B mentions in their book that there can be problems with the drag and drop questions at the exam (such that a previously given answer risks being deleted when you review it). Does anyone know, whether the problems have been fixed?

Best regards
- Morten
Your problem isn't related to inheritance. Instead the problem is that a top level class can't be private (or protected).

Originally posted by srilatha annepu:
am i right
System.out.println(Integer.toBinaryString(4));
given answer:4
mine is:100(as it converts to binary formatt)



Well, the compiler agrees with you . Furthermore, the last time I checked 4 wasn't a binary digit .
Hi Chaitra

Originally posted by chaitra mathur:
As i read an article i understood that strings from the string literal pool cannot be garbage collected.



It might be this article by Corey McGlone you have read. It states that objects in the string pool can't be garbage collected.
Hi Bert

Thank you for your informative post.

Originally posted by Bert Bates:
Just for all of you out there keeping score, remember that although some mock exams might mix the concept of the String pool in with the concept of garbage collection, the real 1.4 and 5.0 exams WILL NOT mix those two together in a question. If the real exam wants to ask about how many objects might be eligible for the GC it will use objects of a type other than String objects.



That's really nice to know, thanks .
Hi Vijay

Thanks for the answer and the links.

Originally posted by Vijay Raj:
Why should it be 2.



As I wrote above, I thought that the string pool manager could choose to GC objects in the pool. However the links you provided have shown that this isn't so.
Hi Sriram

Thank you for your answer.

Originally posted by Sriram Sharma:
I feel its 2.
Because, String "abc" is an object.
This object is created locally and hence eligible for garbage collection.
So, totally there are 2 objects for garbage collection.
What I dont understand is...Aren't the string objects in string pool good enough for garbage colection, if the relevant string objects are not in the scope?
Correct me if I am wrong.



My answer to the question was also "2", because I thought that strings in the string pool could be garbage collected, but the makers of the Enthuware test seems to think differently.
Hi fellow ranchers

In the Enthuware SCJP test one can find the following code:

with the question: "How many objects will be eligible for GC just after the method returns?"

The answer is 1, since "abc" is in the string pool and therefore not eligible for GC, however I'm not sure whether this is true, because I would think that the string pool manager can choose to GC an object from the string pool?

Any thoughts you may have on this will be appreciated.

- Morten
It's a static method, and you can't override static methods.

Originally posted by Paul Anil:
Hi Morten,
It was just a generic message not directed at you We have fixed the error you mentioned. Thanks a lot for the feedback.
-Paul.



OK, sorry. I misunderstood you .

Originally posted by Keith Lynn:
This is from the Java Language Specification.

A new class instance is implicitly created when the string concatenation operator + (�15.18.1) is used in a non-constant (�15.28) expression, resulting in a new object of type String (�4.3.3).



I see, thanks for the answer Keith.
I have tried the following small program:

It prints out "false true", implying that the line marked // 1 actually isn't equivalent with a literal assignment.