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
Which is faster c++ or java?
How many types of jdk are there?
What is an entity in java?
What are tlds in java?
What is ui framework in java?
Why there are no global variables in java?
What is lambda expressions action func and predicate?
In system.out.println(), what is system, out and println?
What do you understand by casting in java language? What are the types of casting?
What is the use of jprofiler?
What is @qualifier in java?
What is property file in java?
Please can anybody explain what exactly "the project architecture" means???
What is flatmap in rxjs?
Explain the inheritance principle.