| Author |
Regarding Inheritance
|
sureshkumar settu
Greenhorn
Joined: May 05, 2010
Posts: 14
|
|
I want to know about inheritance
interface I { public void fun(); }
class A implements I { public void fun() {} }
1. class B extends A implements I { }
2. class C extends A { }
In 1 & 2 both are doing same work, that is inheriting fun(). then What is the purpose of using "implements I" in 1.
is there any specific difference in functionality. Please let me know.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32830
|
|
Welcome to the Ranch
When you say a class implements an interface, then all its subclasses share the same methods and therefore implicitly implement the same interface. It is neither necessary nor harmful to repeat "implements"; it may be beneficial by reminding people about the implementation. There is no difference in functionality.
Try this:
javadoc C.java
. . .
then open the C.html file with a web browser, and you will see a list of implemented interfaces: I.
|
 |
 |
|
|
subject: Regarding Inheritance
|
|
|