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 / udaykiran

Why Not?
Yes, Even we can create an instance of interface and
abstract class also.
just see this below simple example

Main.java
-----------
interface Test
{
public void wish();
}
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();
}
}

cmd> javac Main.java
cmd> java Main
output: hello how r u

in above case Test is an interface but i created the object
for that interface.

Is This Answer Correct ?    54 Yes 92 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a method to check if input string is palindrome?

963


What is the difference between abstract classes and interfaces?

972


Are arrays passed by reference in java?

876


What are the different types of multitasking?

1038


What are examples of modifiers?

1013


Difference between arraylist and hashset in java?

1070


How to sort an array from smallest to largest java?

942


What are the default and parameterized constructors?

1016


Can a class be private or protected in java?

999


What does the @override annotation do?

966


Can we define a package statement after the import statement in java?

1018


What is the difference between serializable and externalizable interface?

1032


Why should we use singleton pattern instead of static class?

887


What is the maximum size of arraylist in java?

943


How objects are stored in java?

983