when Can an object reference be cast to an interface reference?
Answer / praveen kumar
.An interface reference can point to any object of a class that implements this interface i.e. see the example below:
interface Foo{
void display();
}
public class TestFoo implements Foo{
void display(){
System.out.println(“Hello World”);
}
public static void main(String[] args){
Foo foo = new TestFoo();
foo.display();
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
How do you run an executable jar file?
What is an action class in java?
Can the main method be declared final?
What is jsr in java?
Why do we need new date and time api in java se 8?
Which is best framework in java?
What is tier in java?
How do javabeans work?
What's a code group? : java security
What is a service layer in java?
What is the use of flatmap in java 8?
What is the difference between lambda expression and anonymous methods?