Bookmark Topic Watch Topic
  • New Topic

clarification regarding one of the rules of overriding given in scjp 6 study guide by Kathy and Bert

 
kumar ajith
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi
Did not know if needed to start a new topic or continue an older topic of mine but started a new one.

In the Rules of overriding given in scjp 6 study guide by Kathy and Bert (pg. no. 106)

The rules of overriding a method are as follows:

(5)Instance methods can be overridden only if they are inherited by the subclass.
A subclass withing the same package as the instance's super class can override any superclass method that is not marked private or final.
....
(6)...

http://www.coderanch.com/t/487843/Beginning-Java/java/inheritance-polymorphism-across-packages#2194366
In this post in the case 1 -

The Class C3 does not inherit the method met1() from the Class C1, but it overrides the met1(), since met1() is visible in class C3.

So my Question is that rule - a general rule as mentioned in the book ? as I see a contradicting case above or am I missing something.

Thanks in advance
Ajith
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Report post to moderator
Inheritance and the overriding of non-private methods does not
depend on the class packages. So I am confused about how you
see them linked. Can you explain further? Thanks.

Jim ... ...
 
Campbell Ritchie
Sheriff
Pie
Posts: 50180
79
  • Mark post as helpful
  • send pies
  • Report post to moderator
You ought to have continued in the old thread, since this appears to be closely related to the old thread. To avoid duplication, I shall close this thread; please continue discussion in the old thread (link in 1st posting), and copy the link to this thread in your replies.
 
    Bookmark Topic Watch Topic
  • New Topic