Object
Object
In PO programs the data is freely moving around the system and due to which there
are chances of problem in system. So this problem is overcome by OO programs.OO
concepts says it think about data and bind that data and methods those are
manipulating that data into one entity known as object and then utilize that object
into system.
• OBJECT
• CLASS
• ABSTRACTION
• ENCAPSULATION
• DATA HIDING / INFORMATION HIDING
• INHERITANCE
• POLYMORPHISM
Objects: Object represent real world entity into a program. for example an
employee which is real world entity we can make an object of it and then utilize it in
a program with its behaviors and actions.
Some other common definitions
1. Object is an instance of a class.
2. Object is a variable of user defined type / abstract data type.
Class: Class represent template for an object. It actually contains data and there
behavior / methods in it and for utilization of it we need to create an object of that
particular class. we can create n number of object with one class.
Some other common definitions
1. A collection of data and code to handle that data.
2. Class is a user defined type / abstract data type.
3. Class defines basic layout and functionality of an object.
Abstraction: To implement real world entity into program. Class uses the concept of
abstraction.
Some other common definitions
1. Abstraction is a process of mimicking a behavior.
2. Simplifying complex reality by modeling classes appropriate to problem.
3. Abstraction is a process that involves identifying the crucial behavior of an object
and eliminating irrelevant and tedious details.
Encapsulation: Binding the data and code to access that data. Encapsulation only
refers to a container which has a data and its related functions in it.
Some other common definitions
1. When an objects state and behavior are kept together they are encapsulated. The
data and the methods that manipulated that data are stored together in cohesive
unit.
Inheritance: Defining new classes from the existing one. The new class will get all
the methods and properties of the existing class.
The new class known as sub class / child class / derived class.
The existing class known as super class / parent class / base class.
Inheritance is implied by “is-a” or “kind-of” relationship.
Inheritance is basically used for reuse the code and focus to make generic kind of
thing rather than specific one.
Some other common definitions
1. An object can acquire the properties of another object.
Polymorphism: Ability to acquire different forms. There are basically two types of
polymorphism. Compile Time (also knows as Early binding) and Run Time (also
knows as Late binding) Polymorphism.
In Run Time Polymorphism, Object does not know about itself at compile time it
assigns all the properties and methods at runtime. Overriding or inheritance-based
polymorphism are kind of polymorphism. Simple and very common example I am
talking about is if you have a class shape which is inherited to Triangle, Square and
Circle classes. Shape class has a method name as “Draw” which will definitely
inherited to all inherited class. Now, if you declare a variable of shape class and
initialize it with any of the inherited class it will call the method of inherited class.