I know that object which is assigned to the reference variable whose type is an interface could be an instance of a class that implements the interface. But for the following code blocks:
public interface foo {
public abstract void method_1();
}
class bar implements foo {
@Overide
public void method_1() { //Implementation... }
public void method_2() { //Do some thing... }
}
.....
foo variable = new bar();
variable.method_1(); // OK;
variable.method_2(); // Is it legal?
Is it possible to make the variable (whose declared type is foo but actual type is bar) call the method_2 which is not declared in the interface ? Thanks in advance!