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

Can we convert stringbuffer to string?

1055


What is an example of a keyword?

1163


Why spring singleton is not thread safe?

1048


Will the compiler creates a default constructor if I have a parameterized constructor in the class?

1165


java Technical questions asked by JPMC

5142


How do you convert bytes to character in java?

1052


Name some classes present in java.util.regex package.

1071


What is string syntax?

1103


What is nan in java?

1052


how we can make a write-only class in java?

1080


What does flagged out mean?

1117


What is listnode in java?

1037


What is main string [] args?

1044


What is anagram number?

1018


What is the constructor?

1097