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...

can you create interface instance ?

Answer Posted / akthar

No,we can't create an object to an interface...as told uday he create a anonymous class same as Test interface ..if we remove the interface and method it is working ....so t doesnot act as object to an interface it acts as an anonymous class object...so it invoking its anonymous method..

class Main
{
public static void main(String[] args)
{
Test t=new Test()
{
public void wish()
{
System.out.println("output: hello how r u");
}
};
t.wish();
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you understand by garbage collection in Java? Can it be forced to run?

989


What are wrapper classes in java?

1079


How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?

964


what are Hostile Applets?

2086


How to perform quicksort in java?

1117


Is a boolean 1 bit?

1078


What is a singleton factory?

957


Does every java program need a main?

1002


How can constructor chaining be done by using the super keyword?

1094


Can we create a constructor in abstract class?

983


What is the formula to calculate percentage?

1018


Is null in java?

1021


Does java runtime require a license?

1075


Why runnable interface is used in java?

1137


What is java and why do we need it? Explain

1141