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 messaging queue in java?
What is jpa project?
Why java is better than node.js?
How do I open java console?
Can I have multiple main methods in the same class?
What is the use of flatmap in java 8?
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 is maven in java?
can a program use more than one command-line argument?
What is csrf in java?
What does el mean in java?
What is class forname java?
Which version of jdk is required for netbeans 8.0 2?
What is cache in java?
Where are group policies stored? : java security