what is class,object,interface? explain with example
Patel Chirag
Object:
If we see this world with perspective of OOPs, Every thing in this world is treated as object. With OOPs we get power to create Objects of our own and use them according to the need.
Class:
A Class is abstract model which defines a new abstract data type in a programming language, so that we can re-use abstract data type with the help of objects that are instance of class.
Interface:
An interface is a prototype for classes that will implement it and it help them with logical design perspective. Interfaces defines protocols for a class without worrying about the implementation details.
See more
What is object and Class ?
Object is basic runtime entities while class describes all attributes of object as well as method,data type , i.e. class is template of object.
suppose we have a CAR class having attribute and Method like speed,breaks and type of car.Now if we create object of this class then we can say Maruti 800 with 100 km speed,urgent break.
Interface is special type of class which does not impliment method and properties.It defines what class does rather than what class do.All methods and properties are in interface is abstract.Interface never comes in inheritance chain.Interface does not support any type of constructor.
What is the class?
class is the blueprint of a desired object.class describes all the attributes of objects as well as method that implement the behaviour of member object.
What is object?
It is a basic unit of a system. An object is an entity that has attributes , behaviour and identity .Object is member of a class.