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



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

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

More Core Java Interview Questions

What is the purpose of setAutoCommit() ?

1 Answers   Google,


What is run time polymorphism?

6 Answers   eClerx, Elementus Technologies,


How to change the priority of thread or how to set the priority of thread?

0 Answers  


How to use Media tracker Class.

0 Answers  


What is linked hashset and its features?

0 Answers  


Is set sorted in java?

0 Answers  


What is the immediate superclass of Menu?

3 Answers  


Can you override static methods?

0 Answers  


What things should be kept in mind while creating your own exceptions in java?

0 Answers  


What is the base class of all exception classes?

0 Answers  


Does Java support multiple Inheritance?

12 Answers  


How to provide security in java

0 Answers   Infosys, TCS, Tech Mahindra,


Categories