Unit-1 OOPM
Unit-1 OOPM
Research, Indore
www.acropolis.in
Object Oriented Programming and
Methodology (AL305)
With the help of object orientation, we can design new objects using existing objects.
Object oriented programming approach removes the flaws of the procedure oriented
programming approach.
Slide No.
March 27, 2024 7
Introduction to Object Oriented Programming
Object oriented programming is a way of thinking about problems using real world
concept.
The fundamental construct is the object which combines data and functions together.
Up to now, some of the programs we have been writing use a procedural
programming paradigm.
Slide No.
March 27, 2024 8
Introduction to Object Oriented Thinking
In object-oriented programming the focus is on the creation of
objects which contain both data and functions together.
Slide No.
March 27, 2024 9
Object Oriented Programming?
Object oriented programming has been developed to
overcome the limitations of procedural programming.
Slide No.
March 27, 2024 16
Difference between OOP with POP
• The standard output stream normally flows to the screen display and can be
redirected to other output devices.
When variables of one type are mixed with variables of another type, a type conversion
will occur.
Compiler simply follows the rule that “the smaller” type is converted to the “wider”
type.
• C++
• Java
• Simula
• Smalltalk
• Eiffel
• Modula-3
• Self
Slide No.
March 27, 2024 34
Elements of OOPs
1. Class
2. Object
3. Inheritance
4. Data Abstraction
5. Data Hiding
6. Encapsulation
7. Polymorphism
8. Message Passing
Slide No.
March 27, 2024 35
Class
• Class is a user-defined data type.
• A class is like a blueprint for an object.
• It is a logical entity.
• Class is collection of objects of similar type.
Slide No.
March 27, 2024 36
Objects
• This is the basic unit of object oriented programming. That is both data and
function that operate on data are bundled as a unit called as object.
• An object can be defined as an instance of class and there can be multiple
instance of a class in a program.
• An object is a real world entity.
• An object has state and behavior.
object- stud
data – name, rollno., class
function – display, getdata
Slide No.
March 27, 2024 37
Objects
Example of object
Slide No.
March 27, 2024 39
Abstraction
• Data abstraction refers to providing only essential information about the data to
the outside world.
• Hiding the background details or implementation and represents only needed
information to outside world.
• Consider a real-life example: A man driving a car. The man only knows that
pressing the accelerators will increase the speed of the car or applying brakes will
stop the car but he does not know about its internal mechanism.
Slide No.
March 27, 2024 40
Data Hiding
• It is software development technique specifically used in object-oriented
programming.
• It hides the internal object details.
• It also reduces system complexity to increase robustness.
• Example - By declaring the member variables and functions as a private in a
class, the members are hidden from outside the class. Those private members and
data cannot be accessed by the object directly.
Slide No.
March 27, 2024 41
Encapsulation
• Encapsulation is defined as binding together the data and the functions that
manipulate them.
Slide No.
March 27, 2024 42
Polymorphism
• Polymorphism is the ability of a function or operator to act in different forms
depending on the place they are used.
• One task is performed by different ways.
• Ex: A person at the same time can have different characteristics. Like a man at the
same time is a father, a bother ,an employee. So the same person posses different
behavior in different situations. This is called polymorphism.
Slide No.
March 27, 2024 43
Polymorphism
Types of Polymorphism
There are two types of Polymorphism available in C++
•Compile Time Polymorphism
•Run Time Polymorphism
Slide No.
March 27, 2024 44
Dynamic Binding
Binding refers to the linking of a procedure call to the code to be executed in
response to the call.
Dynamic binding means that the code associated with a given procedure is not
known until the time of the call at run-time.
Slide No.
March 27, 2024 45
Message Passing
• It is a form of communication between the objects
• Objects communicate with one another by sending and receiving information to
each other.
• A message for an object is a request for execution of a procedure and therefore
will invoke a function in the receiving object that generates desired results.
Slide No.
March 27, 2024 46
THANKS
March 27, 2024 47