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

What are the important features of Java 9 release?

994


What is basic syntax?

1034


How does singleton class work?

983


What are different types of encoding?

1075


Can we catch more than one exception in single catch block?

1042


What are functions in java?

941


What is subsequence of a string?

1092


Can you write a java class that could be used both as an applet as well as an application?

955


How to sort list of list in java?

1088


How will you compute size of a structure?

1171


what is interface in java? Explain

963


What is a dynamic array in java?

1172


How do I print a “?

995


How does arraylist work in java?

1110


Can a class have multiple superclasses?

1154