user2439099
user2439099

Reputation:

program is compiling even without implementing the interface

I have an interface named abc

public interface abc
{
    void start();
}

and I have an abstract class named def

public abstract class def extends Thread implements abc
{
}

I created another class that extends def called ghj

public class ghj extends def
{
  //it is defing all the methods of its above abstract class
  //now it does not implement the method define in interface start();
}

Please advise if the class ghj does not implement the interface abc required methods then how can the program be compiling?

Upvotes: 6

Views: 147

Answers (2)

Sumit Desai
Sumit Desai

Reputation: 1770

Your full class is already inheriting start() method from Thread class which is having exactly the same signature. That's why compiler is not generating any error.

Upvotes: 2

FThompson
FThompson

Reputation: 28697

Although you are not directly defining start(), by extending Thread, an implementation of start() is being provided to def and its subclasses, therefore fulfilling the contract of the abc interface.

Upvotes: 14

Related Questions