0% found this document useful (0 votes)
21 views

Object Oriented Programming - Introduction

This document introduces object-oriented programming concepts including objects, classes, encapsulation, inheritance, and polymorphism. Objects encapsulate both data and behavior and interact by sending messages. Classes define common characteristics for objects and dictate their behavior. The three main pillars of OOP are encapsulation, which hides implementation details, inheritance, which allows classes to inherit properties from parent classes, and polymorphism, which allows objects to respond differently based on their type.

Uploaded by

sudhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Object Oriented Programming - Introduction

This document introduces object-oriented programming concepts including objects, classes, encapsulation, inheritance, and polymorphism. Objects encapsulate both data and behavior and interact by sending messages. Classes define common characteristics for objects and dictate their behavior. The three main pillars of OOP are encapsulation, which hides implementation details, inheritance, which allows classes to inherit properties from parent classes, and polymorphism, which allows objects to respond differently based on their type.

Uploaded by

sudhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

OBJECT ORIENTED

PROGRAMMING
-Introduction
Objects
• concepts, concrete or abstract, with
meaning derived from the problem
domain “the real world”
• promote an understanding of the
problem domain
• provide a basis for implementation
• encapsulation of state (data values)
and behavior (operations)
Objects (cont.)
• Exhibit behavior by invoking a
method in response to a message
• instances of classes
• an object-oriented program is a
collection of autonomous interacting
and collaborating objects
Classes
• objects sharing common characteristics
• dictate the behavior of the object
• contain
– state: attributes, fields, variables, data
member
– behavior: functions, methods, function
member
• access specifier
• instantiation
• abstract versus concrete
3 Pillars of Object-Orientation
• encapsulation

• inheritance

• polymorphism
Encapsulation
• combination of state and behavior
• implementation details are hidden
internally
• internal mechanisms can change
while public interfaces remain stable
• state may be retrieved using public
methods
• behavior consists of methods
activated by receipt of messages
Inheritance
• organization of classes into a hierarchical
inheritance tree
• data and behavior associated with classes
higher in the tree are accessible to those
classes lower in the tree
• terminology
– ancestor/descendant
– superclass/subclass
– generalization/specialization
Inheritance Diagram
Another Inheritance Diagram
Polymorphism
• polymorphism: many forms
• localizes responsibility for behavior
• object automatically uses correct
implementation for a method
• many objects can respond to the
same message
• minimizes interface parameter
passing
Polymorphism
• determination of method is done at:
– run-time: dynamic binding, late binding
– compile-time: static binding, early
binding
• treat many types (all derived from
the same type) as if they were all
one type
• single piece of interface works on all
these types
Polymorphism Example
3 Pillars of Object-Orientation
• Encapsulation
Combine data structures and algorithm
together and insulate internal code and
data from their interface. Easily to be
reused.
• Inheritance
Reuse the code of the parents as is.
• Polymorphism
Objects of similar type have the same
interface. Easily to be reused.

You might also like