One more doubt from Dan's mock exam
interface I {String s1 = "I";}
class A implements I {String s1 = "A";}
class B extends A {String s1 = "B";}
class C extends B {
String s1 = "C";
void printIt() {
System.out.print(((A)this).s1 + ((B)this).s1 +
((C)this).s1 + ((I)this).s1);
}
public static void main (String[] args) {
new C().printIt();
}
}
What is the result of attempting to compile and run the above program?
a. Prints: ABCI
b. Runtime Exception
c. Compiler Error
d. None of the Above
..
acording to me the ans shud be complier err since a constant declared in a interface is final so cannot be changed once implemented by a class .Am i right ... but the ans is given as a