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

describe synchronization in respect to multithreading? : Java thread

929


What does java ide mean?

1148


Compare overloading and overriding?

1006


In how many ways we can do synchronization in java?

972


Is java a super set of javascript?

1108


What are the types of methodology?

1106


What are the 6 mandatory procedures for iso 9001?

1034


Is the empty set a singleton?

986


Can a class be a super class and a sub-class at the same time? Give example.

1569


What is jvm? Why is java called the platform independent programming language?

1023


What is a variable declaration?

985


What is the difference between interface & abstract class?

1046


What are the limitations of procedural programming approach?

1057


Why string is called as immutable?

956


What are the ways to instantiate the class class?

1105