Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!

Anna Swartz

Greenhorn
+ Follow
since Oct 15, 2002
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 Anna Swartz

Alfred,
IMHO you should not be that concern about the naming, but rather try to train yourself to recognize inner classes inside the code presented in the questions. Especially the anonymous inner classes. And see if they are correctly constructed and are not trying to perform any illegal actions. I just went through the exam two days ago, and my opinion is that they use very clear language in all theoretical questions. There is no ambiguity in that type of questions, so you should not worry about it. I believe they use the “static inner class” name rather then “top-level nested class”.
I did it! This is such a relief! I was required to do it by the end of October (Halloween ). The score, even though is not as flashy, as some of those posted on this forum, is very good for me. I have no prior Java experience, just a several-weeks class with a couple of labs. And then studying for the exam on my own. I started with "Sun Certified Programmer for Java 2 Study Guide" by Brian Bagnall and Harold Cabrera. Being such a greenish-green(green,green)horn, I really liked that book. It gives a lot of clear explanations. Full of typos though (even I could see it). Then I went through "The Complete Java 2 Certification Study Guide: Programmer's and Developers" the third edition, it helped me with some points, but I still think the first one was the best in my situation. Then I discovered JavaRanch! I did a lot of mock tests. Special thanks to Dan Chisholm for all the fine points, I would not be able to get without his questions (I never scored higher then 30% on those ). Thanks very much to Marcus Green for his 3 mock exams, I scored around 80% on those. I was also trying to read "A Programmer's Guide to Java Certification" by Khalid Mughal, because it is so highly recommended by many of the ranchers, but I did not like it at all. For the preparation for the exam I mean. I practiced with J@Whiz, it helped me a lot. I asked a lot of questions on the preparation forum here, and read through even more posted by others. A very, very, very special to Kathy Sierra for thorough answers to all the questions I could think of, and even more so for the moral support .
These notes are pretty good: http://www.geocities.com/technofundo/tech/scjp/scjpnotes.html My problem was though, that I keep reading tem till the very lust minute. By the time the exam started I was worked up so much, I am surprised I even did that goodJ And I could not sleep the night before. My major advice is, try to have some rest before the exam. It is not easy, I could not do it. But I know it affected my score more then anything else.
So, thanks much to JavaRanch and all the ranchers! I am going to stick around.
P.S. Where, did you say, those donations go?
18 years ago
In java all parameters are passed by value. In case of primitives, the copy of the variable is passed while in case of object references, it�s the copy of the reference, which is passed. When the argument is of primitive type, pass-by-value means that the method cannot change its value. When the argument is of reference type, pass-by-value means that the method cannot change the object reference, but can invoke the object's methods and modify the accessible variables within the object. The later is also being referred as pass-by-reference.
Looks good to me! The real question is, which language they are going to use at the exam?
Don,
In your g.c. questions 4-6 one of the options is :
a. An unreachable object can never become reachable again.
You are stating in the answers:
Objects that are unreachable can become reachable again if the finalize method assigns a reference to its instance to a member of another object that is reachable.
Here is an excerpt from the article on the subject (http://www.artima.com/insidejvm/ed2/gcP.html)
It says: "An object is in the RESURRECTABLE state if it is not currently reachable by tracing the graph of references starting with the root nodes, but could potentially be made reachable again later when the garbage collector executes some finalizer. All objects, not just objects that declare a finalize() method, pass through the resurrectable state. As mentioned in the previous section, the finalizer for an object may "resurrect" itself or any other resurrectable object by making the objects reachable again. Because any object in the resurrectable state could potentially be made reachable again by its own or some other object's finalize() method, the garbage collector cannot reclaim the memory occupied by a resurrectable object before it makes certain the object won't be brought back to life through the execution of a finalizer. By running the finalizers of all resurrectable objects that declare a finalize() method, the garbage collector will transform the state of all resurrectable objects, either back to the reachable state (for objects that get resurrected), or forward to the unreachable state.
The UNREACHABLE state indicates not only that an object is no longer reachable, but also that the object cannot be made reachable again through the execution of some finalizer. Unreachable objects can no longer have any affect on the running program. The garbage collector, therefore, is free to reclaim the memory they occupy."
Am I missing something?
Anna.
Kathy, so what is going to happen in this last case you mentioned?
* references passed into other methods -- and what happens if you can't see the code for the method you pass the reference too.
I still do not get it. Let me try again, my understanding was that variable defined in for loop is not reachable outside of that loop. So, once the control is out of the for loop String tmp is ready for the g.c. I even tried to access it right after the loop end or assign it a new value. It would not compile, just like I thought. So, my question is really about the scoop of the variable. I tried to redefine it as new within the method, right after the loop, and it compiles no problem. To me it looks like the scoop for tmp is the loop, not the method. Then why it is not ready for g.c. after loop ends, before method returns. I am really puzzled about that, would appreciate if somebody explains it to me.
class Untitled1 {
public static void main(String[] args){
Untitled1 u = new Untitled1();
u.contDown();
}
public void contDown()
{
for ( int i = 10; i >= 0; i-- )
{
String tmp = Integer.toString( i );
System.out.println( tmp );
}
tmp = "abc";
// String tmp = "abc"; - this will compile,
System.out.println(tmp);
System.out.println("BOOM!");
}
}
Thanks Vijay.
Is it a, b, and d?
18 years ago
Here is a method, which creates a number of String objects in the course of printing a count down sequence. When the program reaches line 8, how many of the String objects created in line 5 , are eligible for garbage collection? Assume that the System.out object is not keeping a reference.
1.public void contDown()
2.{
3. for ( int i = 10; i >= 0; i-- )
4. {
5. String tmp = Integer.toString( i );
6. System.out.println( tmp );
7. }
8. System.out.println(“BOOM!” ;
9.}
Answers:
a.none
b.1
c.10
d.11
c is correct because only the last String object of the 11 created still has a reference. Even though tmp variable is out of scope in line 8, the local variable still has a reference.
I do not understand this explanation, we cannot refer to tmp after line 8. Then why does it still have a reference, and when will it loose it?
Thanks much Don, it is clear to me now!
class Base {}
class Agg extends Base{
public String getFields(){
String name = "Agg";
return name;
}
}

public class Avf{
public static void main(String argv[]){
Base a = new Agg();
//Here
}
}
What code placed after the comment //Here will result in calling the getFields method resulting in the output of the string "Agg"?
Answer: System.out.println( ((Agg) a).getField());
I thought the answer would be:
System.out.println(a.getFields());
I do not understand why we need to downcast. Is not that the case that methods are being invoked based on the underlying object, in this case it is Agg. Or does it have anything to do with the fact that getFields() is not an overriding method because Base does not have it? And in this case if Base would have getFields() and it would be overridden in Agg, then we would not need a downcast?
Congratulations Vijay!
I am going to take my exam next Monday. Would you be able to explain what was tricky part on the garbage collection question? Without revealing the question of course. I keep seeing people mentioning that questions on g.c. are tricky, but have not seen any tricky questions on g.c. in the mock exams. Would you please shed some light on this subject? I will really appreciate it, I am sure, many others will too.
18 years ago
Thanks a lot Jose, I will dwell on this
I keep seeing postings on "certification results" forum saying that garbage collection questions are tough on the real exam. I have not come across any really tough questions on garbage collection on mock exams yet. It makes me nervous to think that I am not preparing properly for the exam as far as garbage collection mechanism is concern. Unless I misinterpret the topic name, and some questions are garbage collection related, when I think that they are not. Can anyone advise? Please!