OOP Concepts
today we are going to study about OOP concepts. Object
oriented programming language is based on the concept of objects. Object
oriented concepts are,
- Object
- Class
- Inheritance
- Polymorphism
- Encapsulation
object
an entity which has state(properties) and behavior is known
as an object. it may be anything and may be logical or physical.Object is an instance of a class.
ex :- dog,pen,tree,car,mother,...etc.
as
we told state and behavior let's discuss it with an example
class
class is a blue print or template of object. Which is a
group of objects have similar properties.
inheritance
when one object acquires all or some properties of another
object it is inheritance. That may the child will acquire their parents
properties.
as an example let's take the supper class as vehicle. A vehicle
has colour,brand,speed,auto/manual etc. Car may be a sub class of above supper class.
That means car has common properties in vehicle class and there may be unique
properties also.
here we use extend as the key word in inheritance.
if car class wants to inherit vehicle class it should
noticed as,
class car extends vehicle
{}
Polymorphism
When one task is performed by different ways is known as
polymorphism.
In java, we use method overloading and method overriding to
achieve polymorphism. And I am going to describe them in later.
Encapsulation
binding or wrapping all the
details in to one is known as encapsulation.
A class will encapsulates all the fields and functions that
are performed on the fields of a class.
in this post I have describe only the simple meanings of oop
concepts and in next posts I am going to show them details with example codes.
Thank you.......!
Comments
Post a Comment