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 does opcode mean?

0 Answers  


What does the @override annotation do?

0 Answers  


What is the primitive type byte?

0 Answers  


What is java reflection api?

0 Answers  


how to handle exceptions in ejb?

1 Answers   HCL,


What methodology can be employed to locate substrings inside a string?

0 Answers  


What are the names of Component subclasses that support painting?

1 Answers  


Which package is used for pattern matching with regular expressions?

0 Answers  


Can string be considered as a keyword?

0 Answers  


Which arithmetic operations can result in the throwing of an arithmeticexception?

0 Answers  


Why is it called buffering?

0 Answers  


what is comparable and comparator interface?

0 Answers  


Categories