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?

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


Please Help Members By Posting Answers For Below Questions

Which is faster c++ or java?

873


How many types of jdk are there?

942


What is an entity in java?

895


What are tlds in java?

816


What is ui framework in java?

837


Why there are no global variables in java?

899


What is lambda expressions action func and predicate?

883


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

953


What do you understand by casting in java language? What are the types of casting?

802


What is the use of jprofiler?

822


What is @qualifier in java?

906


What is property file in java?

838


Please can anybody explain what exactly "the project architecture" means???

2148


What is flatmap in rxjs?

852


Explain the inheritance principle.

880