001package types.multipleInheritance1; 002 003/* 004 * Uncommenting h or g below causes interface K to fail to compile 005 * "The default method h() inherited from I2 conflicts with another method inherited from I1" 006 * 007 * Uncommenting toString below causes I1 to fail to compile, with error: 008 * "A default method cannot override a method from java.lang.Object" 009 */ 010interface I1 { 011 public void f (); 012 default public void g () { System.out.println ("I1.g"); } 013 //public void h (); 014 //default public String toString () { return "I1"; } 015} 016interface I2 { 017 public void f (); 018 //default public void g () { System.out.println ("I2.g"); } 019 default public void h () { System.out.println ("I2.h"); } 020} 021 022interface K extends I1, I2 { } 023 024class C implements K { 025 public void f () { System.out.println ("C.f"); } 026} 027public class Main { 028 public static void main (String[] args) { 029 C x = new C (); 030 x.f (); 031 x.g (); 032 x.h (); 033 } 034}