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 we extract main method from another class?
What is web container in java?
What is a static method?
How do I create an executable jar file?
i have client interview in TCS.client is CITI BANK.how to face it,what type of questions they will ask,please tell send me to kumar525job@gmail.com
What does public static void main(string[]) mean?
What are struts java?
What is difference between map and flatmap in java 8?
Which version of jdk is required for netbeans 8.0 2?
What is a flatmap?
What is an interceptor in java?
What is cloning in java?
How do I install java on windows?
What is javax annotation generated?
What are jpa repositories?