aspose file tools
The moose likes Beginning Java and the fly likes Regarding Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Regarding Inheritance" Watch "Regarding Inheritance" New topic
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
    
    4
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Regarding Inheritance
 
Similar Threads
Please HELP...Devaka Exam Test 2 Number 69. I totally don't understand it.
Regarding object casting
Doubt regarding multiple and hybrid inheritance in java.
Interfaces and Inheritance and exceptions..question
Overriding Static!