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 |
What do you mean by exception handling?
Why serialization is used in java?
What do I need to install netbeans?
What is a java singleton?
What's the difference between authentication and authorization? : java security
Which is best framework in java?
What is tuple2?
What is mq in java?
Is java Class Thread safe ???? How to make java Class Thread safe ??
What if I do not provide the string array as the argument to the method?
What is loose coupling in java?
Can a dead thread be started again?