jaspreet atwal

Ranch Hand
+ Follow
since Sep 05, 2007
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jaspreet atwal

As I already said, A sub class is always considered more specific to a super class. Hence in your code the method with subclass as argument was called.

If you look at the above code you will notice that a method with int argument is called. Where as this would have been a valid call to the other method with long argument as well. But compiler will chose the narrower( or more specific) argument method.

Your code is analogous to the above code. A sub class is always considered more specific to a super class. Hence in your code the method with subclass as argument was called.
"The final local variable is indeed destroyed after the method returns, but since the variable reference has been replaced by the variable value itself everywhere, it is in a way still accessible."

Thank you Akash!! Your answer makes it all clear
What is the scope of a final vairable in a method.

I suppose the x variable should not be accessible once the method ends. Now I read that Method Inner class can access only final local variables and not normal local variables. Because Objects outlive local variables. Won't a final variable be destroyed after a method call completes?

Somebody please explain to me or direct me to somewhere I can understand how Sorted and Ordered are different.

Robert, Sachin and Mustafa, Thank you so much for your replies. This is clear to me now!!
Please help me understand why won't the below code compile?

[ June 09, 2008: Message edited by: jaspreet atwal ]
When a new object is created using new keyword, constructor for that class is called. This constructor will inturn call super()... Now when call to super() is complete, this is the time when it will create all of its instance variables and assign them default values.

So in a constructor the very first thing is a call to super(). Only after all the super construtors have completed, would instance variables for this class be created and instantiated.
Interface declaration is valid, but when you implement an Interface in a class, this class should either provide an implementation for the methods in interface Or should be declared abstract.

Example if you impelement methods:

Example if you declare the class as abstract:

Originally posted by Bert Bates:
Hi guys,

Wow! We're always sorry about errata in the book but I have to say that that is a REALLY old one! Where did you get that book, was it used? Or is it an electronc copy?

No it is a hard copy and I ordered this book over internet from sify.com. Is it a very old edition? Does that mean I'll be at loss if I prepare from this booK? It is from Dreamtech publications. I guess they publish it for India....

You may find it at below link:
[ June 03, 2008: Message edited by: jaspreet atwal ]
[ June 03, 2008: Message edited by: jaspreet atwal ]

Originally posted by Stevi Deter:

The summary is that "addXxxListener" is a valid JavaBean method name. In the context of the review question, "addSize" is not. Read the link for more exhaustive detail.

aah! Thanks Stevi, my wrong...
Phew!! Actually I have covered 5 chapters of K&B. I thought of revising all of these before I jump to Chapter# 6. And this errata made me feel that I still am missing something basic here.

Thanks Guys!!
What are standard JavaBeans name prefixes for methods?

My source of confusion is K&B book. Page# 68 of this book says:

JavaBeans methods must be named using camelCase and depending on the method's purpose, must start with set, get, is, add or remove.

Whereas, Answer 1 to Chapter# 1's SelfTest Question# 5 says:

'add', 'delete', & 'put' are not standard JavaBeans name prefixes

Now why is 'add' mentioned at both places?

In SelfTest section of Chapter 1 of Kathy & Bert Book the second question is a test for abstract classes:

Now according to the Answers given in the book: B is correct, abstract classes don't have to have any abstract methods.

Ok I agree but I thing even B won't compile cause speak method do not have a return statement. Please correct me if I'm overlooking something here.


Originally posted by Sandip Sarkar:
The superclass has no knowledge of the newer exceptions which the sub class is going to throw. And the compiler complains...

Yup, Sandip has pointed the Catch!