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 we create a instance for intwerface?

Answer Posted / amit kumar gautam

Though it is correct that interfaces are basically used for
obtaining the dynamic resoulution of the Method and they
usually can not be instantiated but it is also possible to
instantiate the same in case of anonymous classes and it
works fine.......


class Amit
{

void addCode()
{
Runnable rr=new Runnable()
{
public void run()
{
System.out.print("This is Amit")
}
};
Thread tt=new Thread(rr);
tt.start();

}
}

class Check
{
static public void main(String[]amit)
{
new Amit().addCode();
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a static method be final?

1106


What is the collections api in java programming?

1025


What is break and continue statement?

1166


How do you input a string in java?

1140


What is multi-catch block in java?

1122


What are the types of methodology?

1150


How many decimal places is a double?

1034


How many boolean functions are there?

1010


What is the basic of java?

1063


What is difference between float and double?

1009


Which object oriented concept is achieved by using overloading and overriding?

1183


What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?

2548


Implement a stack with push (), pop() and min() in O(1) time.

1159


Difference between collection, collection and collections in java?

1055


What are different types of multitasking?

1003