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

前端 未结 5 1085
星月不相逢
星月不相逢 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:40

    From Oracle's Java tutorial:

    a class that implements an interface must implement all of the interface's methods. It is possible, however, to define a class that does not implement all of the interface's methods, provided that the class is declared to be abstract.

    Reference document: https://docs.oracle.com/javase/tutorial/java/IandI/abstract.html , section When an Abstract Class Implements an Interface.

提交回复
热议问题