Regarding the first question, I have two quotations from the K&B
SCJP 6 Study Guide:

- "Instance methods can be overridden only if they are inherited by
the subclass."

- "If a method can't be inherited, you cannot override it. Remember that
overriding implies that you're reimplementing a method you inherited!"

So your answer to that question seems to be correct.

Anu satya
Ranch Hand

Joined: Mar 17, 2005
Posts: 146

posted Apr 09, 2010 10:28:33

0

Thank you Nick Puketza and Seetharaman.

According to Nick, i understand that Overriding and Inheritance are related to each other like try-catch block...so, we can't use either of the two. We have to use both. Am i correct? I am bit confussed.

Is it possible to override a constructor?

According to Seetharaman,

What if a class is not the top most class, under what circumstances we can make it protected? is my answer for this is correct? else is there any other answer with respect to design aspects?

Please help me....

One more request..... Nick, can you please send me the link to K&B SCJP 6 Study Guide ? I am planning to take up the exam.

Please

Nick Puketza
Greenhorn

Joined: Apr 01, 2010
Posts: 16

posted Apr 09, 2010 12:41:47

0

Hi Anu,

According to Nick, i understand that Overriding and Inheritance are related to each other like try-catch block...so, we can't use either of the two. We have to use both. Am i correct? I am bit confussed.

First, I think I might have confused you. If so, I'm sorry about that! You can use inheritance
without overriding. For example, you might create an application with two classes, a
superclass and a subclass, in which the subclass inherits all of the superclass methods,
and does not override any of them. (In the subclass you might declare several new
methods, too.)

However, I believe (based on my earlier post) that you cannot override a method unless
it is inherited.

Is it possible to override a constructor?

Constructors cannot be overridden.

One more request..... Nick, can you please send me the link to K&B SCJP 6 Study Guide ? I am planning to take up the exam.