Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Chris Linde

Greenhorn
+ Follow
since Oct 15, 2001
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 Chris Linde

To prepare for this exam, I am preparing to study...
i)RMI
ii)Swing
iii)Networking
iV)Design Patterns
What else should I be studying? Can anyone add to my Christmas hit-list!? Should I study CORBA?
I have two classes:
File 1:
package MyPackage;
class Balance{
String name;
int bal;
Balance(String n, int b){
name = n;
bal = b;
}
void show(){
if(bal>0)
System.out.println("--> " + name + " " + bal);
}
}
File 2:
package MyPackage;
class AccountBalance{
public static void main(String args[]){
Balance current= new Balance("Me", 0);

}
}
These seperate files both include the package statements, and are both physically located inside the MyPackage directory. The directory structure is:
C:\Exam\MyPackage
I have fooled around with various import statements, tried moving to the above directory, mumbulled incantions to several fire-gods, but I can't get these to compile. What should I do!?!?
18 years ago
Hello Fengqiao,
I think I understand the source of your confusion, but please elaborate if I misunderstand you. If you are wondering why it is that the method returns -1 instead of returning 0 , then one has to understand that when a statement in a try-block throws an exception, the execution flows down to the matching catch statement. If there is not a catch-block that can deal with the type of exception thrown in the try-block, the execution procedes directly to the finally statement, and then the execution flows up to the method that called the method containing the try-block, the rest of the code inside the method that contained the try-block does NOT execute. Therefore the return 0 statement at the bottom of the method never executes. If you want this method to return 0, place the return 0 statement inside the finally block, where it will override the return -1 statement in the catch-block.
finally{
System.out.println("Doing finally");
return 0;
}
Hope I helped!
Muchas Gacias to Sid and Mark. I prefer a wide variety of learning resources, but there is something comforting about knowing that I have already found what is in the general consensus to be the best resource around.
I would not even consider writing the Developer Exam without consulting this site on a regular basis. I agree that there is no better tool for sharping one's knowledge. However, as neccesary as this site is, I find books provide an equally important ingredient for preparing for the test (especially for those of us who are relatively new to Java), and that ingredient is structure. My SCJP Exam books have been like a roadmap, while this site has helped me appreciate the view. If anyone could recommend a good road map to me, I would be grateful.
From what I have read, one consideration when deciding wether to extend the Thread class or implement Runnable depends on wether you want to be able to pass your object to many different threads over the course of your objects lifetime (in which case it would be a good idea to implement Runnable and pass your object to a different Thread whenever you want). If on the other hand the code in your run() method is tightly coupled to the rest of the code in your object then you may be better off by having your class extend Thread. This is pretty new to me but I believe it is of such importance it should be mentioned.
Question: I have read that when a Thread enters a method it gets it's own copy of that method's local variables. The loop counter variable(i) is local to run(). Is it the case that this code produces 20 pairs of values because there are TWO copies of i (and therefore, 20 executions of the println() statement). Can someone please correct me if I am wrong and elaborate.
Chris says thanks.
Hello everybody,
My question to anyone who wants to answer: If you had one month to get ready for the Developer's exam, were stuck on a desert island, and could only bring ONE book to the island with you......which book would you bring?!?!?
Greetings.
I would like to know what the CLASSPATH is, and how Java uses it. Some of the material I have read on it seems vague and a bit too abstract. I would be grateful for any assistance.
18 years ago
I am wondering what memory scheme is used to layout a Hashtable in Java. Is it the case that an array holds all the keys, and each key points to the address of it's corresponding value object which exists somewhere out there in memory? Or is it more like a two dimensional array, where each 'bucket' holds key/value pairs right next to each other? If anyone can help me understand this I would be grateful!
18 years ago