Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

For each of the following program segments,give a big zero analysis for the running time 1.For (i=0;i<m;i++) { // } 2.For (j=0;j<i;j++)

0 Answers   St. Pauls University,


can a program use more than one command-line argument?

0 Answers  


Why java?

0 Answers  


What is type inference? Is type inference available in older versions like java 7 and before 7 or it is available only in java se 8?

0 Answers  


What is entitymanager in jpa?

0 Answers  


What is mq in java?

0 Answers  


Is jar an executable?

0 Answers  


Why do we need new date and time api in java se 8?

0 Answers  


Which framework is best for rest api java?

0 Answers  


Why do we need framework in java?

0 Answers  


Why Java is a platform independent language?Explain byte code and JVM

8 Answers   HCL,


What is the meaning of loosely coupled in java?

0 Answers  


Categories