The program compiles even without implementing an interface

I have an interface named abc

 public interface abc { void start(); } 

and I have an abstract class called 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 ghj class ghj not implement the required abc interface methods, then how can the program be compiled?

+6
source share
2 answers

Although you do not directly define start() by extending Thread , def provides an implementation of start() and its subclasses, so we execute the abc interface contract.

+14
source

Your complete class already inherits the start() method of the Thread class, which has exactly the same signature. Therefore, the compiler does not generate any errors.

+2
source

Source: https://habr.com/ru/post/946237/


All Articles