An abstract class in Java need not implement any methods from its implementing interface. Why?

前端 未结 5 1083
星月不相逢
星月不相逢 2021-02-04 14:08

Let\'s look at the following simple code snippet in Java.

interface Sum
{
    abstract public void showSum();
}

interface Mul
{
    abstract public void showMul         


        
5条回答
  •  伪装坚强ぢ
    2021-02-04 14:29

    Because it's abstract. An abstract class is a class which is allowed to declare some methods without providing any implementation of those methods, forcing concrete subclasses doing it. You could add the method

    @Override
    public abstract void showSum();
    

    to the abstract class, but it would just be redundant with the method already declared in the interface.

提交回复
热议问题