一个类实现两个接口。方法属于哪个接口? [英] A class implements two interfaces. Which interface does a method belong to?

查看:123
本文介绍了一个类实现两个接口。方法属于哪个接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个接口 B C 每个接口都有相同的方法 public m1( )

There are two interfaces B and C each having the same method public m1()

class A implements B and C 

如果类 A 必须实现方法 m1(),实现的方法将是哪个接口?

If class A has to implement method m1(), the implemented method would be of which interface?

推荐答案

我想我们可以说A.m1实现了两个B .m1和C.m1。因为两者

I think we can say that A.m1 implements both B.m1 and C.m1. Because both

B b = new A();
b.m1();

C c = new A();
c.m1();

将起作用

这篇关于一个类实现两个接口。方法属于哪个接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆