Is object overlay also inherited?

When a class implements an interface, do subclasses inherit implemented interfaces? for example

class A implements Runnable
{
   public void run()
   {
     // do something
   }
}

class B extends A
{
   public static void main(String[] args)
   {
       new Thread(new B()).start(); //works
   }
}

Does this mean that implements clause is also inherited?

+3
source share
4 answers

Class A IS-A Runnable and Class B IS-A A, so Class B IS-A RUNNABLE. Yes they do.

+5
source

Yes, B both extends A and implements Runnable.

+1
source

That's right. This is exactly how it works.

+1
source

Of course. B is also Runnable due to parent B (A) is Runnable.

0
source

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


All Articles