when Can an object reference be cast to an interface reference?



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

Post New Answer

More Java Related AllOther Interview Questions

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

0 Answers   TCS,


What is aop in java?

0 Answers  


What is jpa implementation?

0 Answers  


Is java Class Thread safe ???? How to make java Class Thread safe ??

1 Answers   Cognizant, TCS,


What are all the documents have you involved in preparation of a Project as a Project Lead?

2 Answers  


What is the means of java?

0 Answers  


What is resultsetmetadata in java?

0 Answers  


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.

0 Answers  


What is meant by annotations in java?

0 Answers  


In system.out.println(), what is system, out and println?

0 Answers  


How do I install java on windows?

0 Answers  


What is lambda value?

0 Answers  


Categories