/* * T05n06.java -- What happens when you implement interfaces that share * a method signature. * * Answer: Not much! Java has no problem with it. * * Java may not care, but logically there is the potential for a problem. * Interface A may want method doIt() for one purpose, while Interface * B may want doIt() for something very different. If you implement * doIt(), you are satisfying the requirements of Java interfaces, but * you may be creating a logical disaster. * * This program doesn't do anything useful, other than to demonstrate * what happens in this situation. */ import java.io.*; interface A { public int foo(); } interface B { public int foo(); } class C implements A,B { public int foo() { return 0; } } public class T05n06 { public static void main (String [] args) { C c = new C(); System.out.println("foo() returns " + c.foo()); } }