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 is the content reside in Use case Document?
what is the difference between Collaboration and Java Collaboration definition interms of JAVACAPS terminology?
What is an api in java?
What is the most important feature of java?
What is native api in java?
What if I do not provide the string array as the argument to the method?
What is mdb in java?
What is the difference between a jdk and a jvm?
Where is java installed?
Is lambda functional programming?
What are microservices in java?
Explain suspend() method under thread class>