Hi,
I am new to this group. I am preparing for the programmers certification exam. I had a doubt regarding Interfaces. If u run the following program,,,
interface A {
String s1 = "A";
String m1();
}
interface B extends A {
String s1 = "B";
String m1();
}
class InterfaceExample implements B {
public String m1() {return s1;}
public static void main(String[] args) {
A a = new InterfaceExample();
System.out.print(a.m1());
}
}
The output is B. But I thought, since a is of type Interface A, the string returned will be that declared in Interface A. Can anyone please give an explanation for the output.
Thank you
Vamshi