Professional Documents
Culture Documents
CHAPTER IN BOOK- 0
OBJECT ORIENTED
PROGRAMMING
-K. Indhu
K. INDHU
GOALS
1. What is an Object ?
2. What is a Class ?
3. What is a Message ?
4. Conditions to be Object Oriented ?
5. What is Encapsulation ?
6. What is Abstraction ?
7. Objects Access Levels (Visibility) ?
8. What is Inheritance ?
9. Inheritance Pictorially ?
10.Properties of Inheritance ?
11.Benefits of Inheritance ?
12.What is Polymorphism ?
13.Types of Polymorphism ?
14.What is Dynamic Binding ?
K. INDHU
WHAT IS AN OBJECT ?
What is an Object?
-> An object is a software bundle of related variables
and methods.
-> Software Objects are often used to model realworld objects which we come across in everyday life.
K. INDHU
WHAT IS A CLASS ?
What is a Class?
-> A class is a blue print or prototype that defines
the variables & the methods, common to all objects
of a certain type.
-> A class encapsulates both data & operations.
-> Object is run-time instance of class.
-> Classes just sit there, objects do the real work.
-> Memory is allocated for Objects, not for Classes.
K. INDHU
WHAT IS A MESSAGE ?
What is a Message ?
-> Software Objects interact & communicate with each
other using messages.
-> Programmatically, Methods (functions in C) are called
as Messages.
K. INDHU
CONDITIONS TO BE OBJECT
ORIENTED
To be object oriented, a language must support->
->
->
->
->
->
Encapsulation,
Abstraction,
Inheritance,
Polymorphism,
Dynamic Binding.
C++
Smalltalk
Java
Eiffel
C#
K. INDHU
WHAT IS ENCAPSULATION ?
What is ENCAPSULATION ?
-> Packaging an Object's variables within the protective
custody of it's methods is called Encapsulation.
-> "Data Binding" is called as "Encapsulation.
K. INDHU
WHAT IS ABSTRACTION ?
What is Abstraction ?
-> "Data Hiding" is called as "Abstraction".
-> Often, for practical reasons, an object may wish
to expose some of it's variables or hide some of
it's methods.
-> Thus hiding features ( un necessary to end-user
) of an object and exposing ( only needed info. to
end-user ) of an object is called as Abstraction.
-> For example- TV Set.
K. INDHU
K. INDHU
10
WHAT IS INHERITANCE ?
What is Inheritance ?
-> A class inherits state & behavior from it's
super-class / base-class.
-> Inheritance provides a powerful & natural
mechanism for organizing and structuring
software programs.
-> Inheritance also provides a mechanism
for re-using already created data and
methods from super-class in it's sub-classes.
K. INDHU
11
INHERITANCE PICTORIALLY
K. INDHU
12
PROPERTIES OF INHERITANCE ?
Properties of Inheritance->
-> Each sub-class inherits state (in the form of variable
declarations) from the super-class.
-> Sub-classes can add variables and methods additionally
apart from the ones they inherit from the super-class.
-> Sub-classes can also override inherited methods and
provide specialized implementations for those methods.
-> We are not limited to just one layer of inheritance.
-> The inheritance tree, or class hierarchy, can be as deep
as needed.
K. INDHU
13
BENEFITS OF INHERITANCE ?
Benefits of Inheritance->
(1) Re-Usability: -> Subclasses provide specialized behaviors.
-> Superclass provides generalized behaviors.
-> Through the use of inheritance, programmers
can re-use the code in the superclass many times.
(2) Can define Abstract Classes: -> Programmers can implement superclasses called
abstract classes that define generic behaviors.
K. INDHU
14
WHAT IS POLYMORPHISM ?
What is Polymorphism ?
-> The ability to appear in many forms.
-> In object-oriented programming, Polymorphism
refers to a programming language's ability to
process objects differently, depending on their data
type or class.
-> It is the ability to re-define methods for derived
classes.
-> (eg) e-bike Acceleration system.
Electronically / Mechanically
K. INDHU
15
TYPES OF POLYMORPHISM ?
K. INDHU
16
17
SO FAR WE STUDIED
Object Oriented Programming
K. INDHU
18
HAPPY
LEARNING!!!