java - 使用具有相同方法的两个接口(interface)实现多重继承

标签 java oop multiple-inheritance

我理解多重继承的概念,尽管我试图访问两个接口(interface)中给出的相同方法。示例:-

interface Interface1{ 
       int show();
       void display();
}
<小时/>
interface Interface2 {
int show();
void display();
}
<小时/>
class Impl implements Interface1, Interface2 {
       // how to override show() and display() methods such that 
       // i could access both the interfaces
}

最佳答案

由于接口(interface)没有方法定义。您覆盖哪个接口(interface)的 show 方法并不重要。

关于java - 使用具有相同方法的两个接口(interface)实现多重继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9768204/

相关文章:

java - 如何通过 bundle 发送双值

java - 确定任何网络应用程序和独立应用程序所需的 -Xmx 和 -Xms 的最佳方法

class - 如何通过 "actual"类找到实例变量?

C++ OO设计: Inheritance of template parameter

c++ - 以不止一种方式向上转换为作为基类的 C++ 类(无需使用虚拟继承)

java - jdk-13.0.2因为logisim导调用脑不可见

PHP - 克隆一个包含对自身的引用的对象?

java - 实现阻塞接口(interface)

c++ - 在多级继承的情况下无法理解虚拟基类构造函数

java - 如何使 JSONObject 的 toString() 将 UTF-8 字符编码为 un​​icode,就像 PHP 的 json_encode 中一样?