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 predicate in lambda expression?
In system.out.println(), what is system, out and println?
How to reverse the singly linked list(In Node data members are(int data,int pointerTONext))
In hibernate what is the difference between the Session and SessionFactory?
How do I open the java console in windows 10?
What is the difference between collection and stream?
How do I enable java in google chrome?
What is profile in java?
Write a program for the following topic - switch case,looping using fuction calling,nesting,console input output. Aim- to print a menu:- 1-series 2-single value. Each menu having sub menu armstrong or perfect.
Which is more secure: java or activex? : java security
How do javabeans work?
What is hql in java?