when Can an object reference be cast to an interface reference?
Answer / 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 |
What is persistence xml in java?
explain isalive() method under thread class?
What is cmp in java?
What is the difference between jar and executable jar?
Can an application have multiple classes having main method?
What are tlds in java?
What is injection in java?
If you’re overriding the method equals() of an object, which other method you might also consider?
What is flatmap in rxjs?
What is tuple2?
What are anonymous methods and lambda expression?
What is the difference between lambda expression and anonymous methods?