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
Can a method be static and synchronized?
What is meant by rest api in java?
What is jpa entitymanager?
what is reflection api? How are they implemented?
what about jdb and javadoc by example ?
can anyone tell me what kind of questions are asked for core java exam in aptech
How do javabeans work?
What is serializable in java?
What does persist mean in java?
I am trying to create a new universal user group. Why can't i? : java security
What is csrf in java?
Why is javac not recognized?
Explain issues of old java date api?
Are there tuples in java?
What is an api in java?