when Can an object reference be cast to an interface reference?
Answer Posted / 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 |
Post New Answer View All Answers
What is meant by rest api in java?
How do I download and install eclipse on windows 10?
What is a java proxy?
How do you find lambda?
What happens when the parent process of a child process exits before the child ?
What is jndi datasource in java?
How do I start netbeans?
What is transient in java?
What is war file in java?
What is cdi bean in java?
What is hql in java?
What can open a jar file?
Can an application have multiple classes having main method?
Why do we create dto in java?
What is stateless object in java?