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 java se?
What is interceptor in java?
When a thread is created and started, what is its initial state?
What kind of thread is the garbage collector thread?
Topic- looping,function overloading,nesting ,polymorphism. Aim - to write a function with a name buzz-buds,that will check whether the given numbers are buddies or not on the basis of no. of parameters passed during function calling.
What's the difference between authentication and authorization? : java security
Why are lambda functions called lambda?
How do I install java on windows?
What is an entity in java?
What is static class in java?
What is the use of servlet in java?
What is dao in java?
Can we write lambda without functional interface?
What is lambda value?
What is gui in java with examples?