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

we cannot create an object of interface but we can create
a variable of it

Answer Posted / mahesh

For creating an object, interface does not contain the body of its abstract methods. Hence compiler does not have enough data for creating an object out of it.
On the other hand you can create a variable of that interface with any other class implementing that interface.
E.g. A is an interface and B is a class implementing A.
Now if you create
A obj = new A();
This statement wont give an implementation of methods inside A.
But,
class B implements A{
}

A obj = new B();
Here class B will be defining all the abstract methods inside interface A.
Hence it is not possible to create an object of interface but you can create a variable of it.

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there any difference between synchronized methods and synchronized statements?

1058


Can we use both this () and super () in a constructor?

970


Is final static java?

964


What do you know about java?

901


Make a data structure and implement an algorithm to print all the files in a directory. (The root directory can have sub-directories too.)

1289


Why string objects are immutable in java?

1002


What is used of static keyword in java?

1012


What is difference between iterator access and index access?

1016


what is mena by object block any what is the use of that

2167


When can you say a graph to be a tree?

1040


Explain different ways of creating a thread?

998


What are synchronized methods and synchronized statements in java programming?

975


Difference between object instantiation and construction ?

1015


What is fundamental datatype?

945


what is daemon thread and which method is used to create the daemon thread? : Java thread

913