
/** 
  * file : MultII.java
  * The deadly diamond with java interfaces 
  * remember interface members are static and final 
  */ 

interface A { int a = 1; } 

interface B extends A { int  a = 10 , b = 2; } 

interface C extends A { int c = 3; } 

class D implements B,C {

 	// NOTE: no var a in this class

	public int getSuperA(){return A.a; }
}

public class MultII { 	
	D d; 	
	public MultII() { d = new D(); }
	
	public static void main(String[] args) {		
		MultII m2 = new MultII();
 		System.out.println("d.b is: "+m2.d.b);
		System.out.println("d.c is: "+m2.d.c);
		System.out.println("m.d.getSuperA() is: "+m2.d.getSuperA());
					
		/*
		 * Everything is ok until:
 		 * 
		 * System.out.println("d.a is: "+m2.d.a);
		 * Reference to a is ambiguous. It is defined in interface A and
		 * interface B.
                 * System.out.println("d.a is: "+m2.d.a);
		 *
		 * Does this look familiar ?
 		 */


		if(m2.d instanceof A)
		 	System.out.println("\nd \"is an\" A");
		if(m2.d instanceof B)
		 	System.out.println("d \"is a\"  B");
		if(m2.d instanceof C)
		 	System.out.println("d \"is a\"  C");
}}//MultII
