类扩展并实现

时间:2020-05-01 09:10:23

标签: java spring

@Service    
public class SpecialityMapService extends AbstractMapService<Speciality, Long> implements SpecialitiesService {}

如果类扩展到另一个类并同时实现接口会发生什么?

1 个答案:

答案 0 :(得分:1)

它可以继承超类的方法,并且需要定义接口中定义的方法。如果超类是抽象的,则子代将需要根据要求重新定义继承的方法。使用线程时,您可以看到相同的内容。

    public class MultiThreading extends Thread implements Runnable {
      // Can inherit methods from Thread Class
      // Must implement the run() method from Runnable interface.
      public void run() {
     }
     }
相关问题