Object Oriented Programming System
OOPS part II
Learning Objectives
 Data Abstraction
 Encapsulation
 Inheritance
 Polymorphism
 Significance of OOP
OOPS
Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively
2
OOP Concepts
 The object oriented programming has been developed
with a view to overcome the drawbacks of conventional
programming approaches.
 The OOP approach is based on certain concepts that
help it attain its goal of overcoming the drawbacks or
shortcomings of conventional programming approaches.
 These concepts are: Data Abstraction, Encapsulation,
Inheritance and Polymorphism.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively
3
Data Abstraction
 Abstraction is the concept of simplifying a real world
concept into its essential elements.
 Abstraction refers to the act of representing essential
features without including the background details or
explanations.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively
4
Data Abstraction Example
 You are driving a car.
 You only know the essential features to drive a car e.g., gear
handling, steering handling, use of clutch, accelerator, brakes
etc. etc.
 What is happening inside (in wiring, petrol tank, motor etc) is
hidden from you.
 This is abstraction where you only know the essential things
to drive a car without including the background details or
explanations.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
5
Evolution of Software
3rd Generation Languages are termed as High Level
Languages because they
 offer English like keywords,
 offer constructs for sequence, selection (decision) and
iteration (looping),
 very easy to program with such languages compared to low
level languages as they are near to spoken languages
 Examples : Fortran, Pascal, C, COBOL, Basic etc.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
6
Evolution of Software
 4th Generation Languages are non-procedural i.e.
no need to write detailed programs e.g. SQL.
 5th Generation Languages pertain to Artificial Intelligence .
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
7
The low level languages are close to the machine as they represent machine’s
working in better way and the high level languages are close to the programmer
as they are more English like.
However, the languages ‘C’ and ‘C++‘ serve both the aspects, hence can be called
as ‘middle level languages’.
 Let us now talk about Programming Paradigms.
What do think a paradigm is ?
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
8
Programming Paradigms
 By paradigm one means a way of thinking or doing
things.
 Paradigm means organizing principle of a program. It is an
approach to programming.
 So, Programming Paradigm means:
‘way of writing a program’.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
9
1. Procedural Programming paradigm
Procedure is more important, that is, instructions telling
how to do a thing but the data get ignored.
For Example,
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
10
Different Programming Paradigms
2. Modular Programming paradigm
This is extension of Procedural Programming paradigm.
When a program becomes too large with Procedural
programming, it is subdivided into smaller modules, hence
the name.
For Example,
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
11
Different Programming Paradigms
 In modular programming, since many modules (or functions)
access the same data, the way the data is stored becomes critical. The
arrangement of the data can’t be changed without modifying all the
functions that access it.
 Their chief components functions etc. do not model the real world very
well.
For instance, a procedural program for library maintenance aims at the
operations Issue, Return etc. whereas the real world entities are Books.
But ‘Books’, the data, are given second-class status in the program.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
12
Issues with Procedural & Modular
Paradigms
OOP and Classes/Objects
 The object oriented programming has been developed
with a view to overcome the drawbacks of conventional
programming approaches.
 Classes and Objects are the building blocks of this paradigm.
 The object-oriented approach views a problem in terms of
objects involved rather than procedures for doing it.
 Let us now understand what is an object and what’s a class ?
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
13
Classes and Objects
 Object - An Object is an identifiable entity with some
characteristics and behaviour.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
14
(CHARACTERISTICS)
1. spherical shaped
2. colour is orange
3. rough peel/rind
Orange
(IDENTITY)
(BEHAVIOUR)
1. citrus/juicy
2. sweet-sour taste
3. rich in Vitamin C,
fiber and folic acid
For example, Orange is an object.
Classes and Objects contd.. OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
15
Look around you, you’ll find many objects e.g.,
- the fan on your ceiling,
- the chair you are sitting on,
- the computer you are looking at,
- the notebook, books lying next to you,
etc are all examples of objects.
 Ceiling Fan is another example of object.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
16
Classes and Objects contd..
(CHARACTERISTICS)
1. has three blades
2. colour is brown
3. has a motor
Fan
(IDENTITY)
(BEHAVIOUR)
1. circulates air
2. rotates at a
specific speed
 You yourself (a human being) are also an object.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
17
Classes and Objects contd..
(CHARACTERISTICS)
1. has eyes, ears,
heart, brain, arms,
legs, lungs etc etc Your Name
(IDENTITY)
(BEHAVIOUR)
1. Can walk, talk, eat,
sing etc
2. can take decisions
etc
3. And many more
 Can you think of other objects around you?
 Following are some more objects that you see in day-to-day life.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
18
Classes and Objects contd..
Can you figure out three things for these i.e. their identity,
characteristics and behaviour?
A bank account, an animal, a pen, a chair, a curtain, teacher,
student, library membership etc.
Out of these, bank account and library membership objects are
abstract objects i.e. these are non-physical.
 In the light of these examples, look closely around
you.
You’ll find that everything around you is an object as it has :
 an identity ( its name)
 Some characteristics( physical attributes)
 Some behaviour (functionality)
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
19
Classes and Objects contd..
Now you can identify that since OOPS deals with objects only, hence
it is near to real world as real world is filled with objects only.
 Class –
A Class is a template/blueprint representing a group of
objects that share common properties and relationships.
For example,
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
20
Classes and Objects contd..
Now,
Can you tell the difference between a
class and an object?
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
21
Classes and Objects contd..
Procedural vs. OOP Programming
 Procedural Programming views a problem or situation
in terms of procedures and then the data that procedures
use.
 OO Programming views a problem in terms of objects
involved as the objects themselves take care of data involved
(through characteristics) and procedures involved (through
behaviour).
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
22
Procedural vs. OOP Programming
Let us simulate traffic flow at a red light crossing.
 Using procedural programming paradigm, the above said
problem will be viewed in terms of working happening in the
traffic-flow i.e., moving, accelerating, halting, turning etc.
 The OOP paradigm, however, aims at the objects and their
interface. Thus in OOP approach, the traffic-flow problem will
be viewed in terms of the objects involved. The objects
involved are : cars, trucks, buses, scooters, auto-rickshaws,
taxis etc.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
23
Let us Revise now
 Programming started with 1st Generation Language Machine language which
is comprised of 0s and 1s i.e. Binary Language.
 2nd Generation Language was Assembly Language which comprises of codes called
Mnemonics for instructions.
 First two generations of languages are called Low-level Languages.
 3rd Generation Languages were High Level Languages(HLL) that have instructions as
English Like and are easier to read, understand and debug. Examples include
Fortran, Basic, C, Pascal, COBOL etc.
 4th Generation Languages are non-procedural e.g. SQL.
 5th Generation Languages are Artificial Intelligence compatible.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
24
Let us Revise now
 Programming Paradigm means ‘way of writing a program’.
 In Procedural Programming paradigm, procedure is more important, that is,
instructions telling how to do a thing but the data get ignored.
 In Modular Programming Paradigm, a big procedure of procedural paradigm is
broken down in smaller modules.
 Procedural and Modular paradigms do not model the real world well.
 Object Oriented Programming paradigm designs a solution by considering the
objects involved in the problem.
 An Object is an identifiable entity with some characteristics and behaviour.
 A Class is a template/blueprint representing a group of objects that share common
properties and relationships.
OOPS
MAIN MENU Click Right Arrow and Left arrow buttons to navigate to
next and previous screens respectively.
25

OOPS.pptx

  • 1.
    Object Oriented ProgrammingSystem OOPS part II
  • 2.
    Learning Objectives  DataAbstraction  Encapsulation  Inheritance  Polymorphism  Significance of OOP OOPS Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively 2
  • 3.
    OOP Concepts  Theobject oriented programming has been developed with a view to overcome the drawbacks of conventional programming approaches.  The OOP approach is based on certain concepts that help it attain its goal of overcoming the drawbacks or shortcomings of conventional programming approaches.  These concepts are: Data Abstraction, Encapsulation, Inheritance and Polymorphism. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively 3
  • 4.
    Data Abstraction  Abstractionis the concept of simplifying a real world concept into its essential elements.  Abstraction refers to the act of representing essential features without including the background details or explanations. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively 4
  • 5.
    Data Abstraction Example You are driving a car.  You only know the essential features to drive a car e.g., gear handling, steering handling, use of clutch, accelerator, brakes etc. etc.  What is happening inside (in wiring, petrol tank, motor etc) is hidden from you.  This is abstraction where you only know the essential things to drive a car without including the background details or explanations. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 5
  • 6.
    Evolution of Software 3rdGeneration Languages are termed as High Level Languages because they  offer English like keywords,  offer constructs for sequence, selection (decision) and iteration (looping),  very easy to program with such languages compared to low level languages as they are near to spoken languages  Examples : Fortran, Pascal, C, COBOL, Basic etc. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 6
  • 7.
    Evolution of Software 4th Generation Languages are non-procedural i.e. no need to write detailed programs e.g. SQL.  5th Generation Languages pertain to Artificial Intelligence . OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 7 The low level languages are close to the machine as they represent machine’s working in better way and the high level languages are close to the programmer as they are more English like. However, the languages ‘C’ and ‘C++‘ serve both the aspects, hence can be called as ‘middle level languages’.
  • 8.
     Let usnow talk about Programming Paradigms. What do think a paradigm is ? OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 8
  • 9.
    Programming Paradigms  Byparadigm one means a way of thinking or doing things.  Paradigm means organizing principle of a program. It is an approach to programming.  So, Programming Paradigm means: ‘way of writing a program’. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 9
  • 10.
    1. Procedural Programmingparadigm Procedure is more important, that is, instructions telling how to do a thing but the data get ignored. For Example, OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 10 Different Programming Paradigms
  • 11.
    2. Modular Programmingparadigm This is extension of Procedural Programming paradigm. When a program becomes too large with Procedural programming, it is subdivided into smaller modules, hence the name. For Example, OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 11 Different Programming Paradigms
  • 12.
     In modularprogramming, since many modules (or functions) access the same data, the way the data is stored becomes critical. The arrangement of the data can’t be changed without modifying all the functions that access it.  Their chief components functions etc. do not model the real world very well. For instance, a procedural program for library maintenance aims at the operations Issue, Return etc. whereas the real world entities are Books. But ‘Books’, the data, are given second-class status in the program. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 12 Issues with Procedural & Modular Paradigms
  • 13.
    OOP and Classes/Objects The object oriented programming has been developed with a view to overcome the drawbacks of conventional programming approaches.  Classes and Objects are the building blocks of this paradigm.  The object-oriented approach views a problem in terms of objects involved rather than procedures for doing it.  Let us now understand what is an object and what’s a class ? OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 13
  • 14.
    Classes and Objects Object - An Object is an identifiable entity with some characteristics and behaviour. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 14 (CHARACTERISTICS) 1. spherical shaped 2. colour is orange 3. rough peel/rind Orange (IDENTITY) (BEHAVIOUR) 1. citrus/juicy 2. sweet-sour taste 3. rich in Vitamin C, fiber and folic acid For example, Orange is an object.
  • 15.
    Classes and Objectscontd.. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 15 Look around you, you’ll find many objects e.g., - the fan on your ceiling, - the chair you are sitting on, - the computer you are looking at, - the notebook, books lying next to you, etc are all examples of objects.
  • 16.
     Ceiling Fanis another example of object. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 16 Classes and Objects contd.. (CHARACTERISTICS) 1. has three blades 2. colour is brown 3. has a motor Fan (IDENTITY) (BEHAVIOUR) 1. circulates air 2. rotates at a specific speed
  • 17.
     You yourself(a human being) are also an object. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 17 Classes and Objects contd.. (CHARACTERISTICS) 1. has eyes, ears, heart, brain, arms, legs, lungs etc etc Your Name (IDENTITY) (BEHAVIOUR) 1. Can walk, talk, eat, sing etc 2. can take decisions etc 3. And many more
  • 18.
     Can youthink of other objects around you?  Following are some more objects that you see in day-to-day life. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 18 Classes and Objects contd.. Can you figure out three things for these i.e. their identity, characteristics and behaviour? A bank account, an animal, a pen, a chair, a curtain, teacher, student, library membership etc. Out of these, bank account and library membership objects are abstract objects i.e. these are non-physical.
  • 19.
     In thelight of these examples, look closely around you. You’ll find that everything around you is an object as it has :  an identity ( its name)  Some characteristics( physical attributes)  Some behaviour (functionality) OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 19 Classes and Objects contd.. Now you can identify that since OOPS deals with objects only, hence it is near to real world as real world is filled with objects only.
  • 20.
     Class – AClass is a template/blueprint representing a group of objects that share common properties and relationships. For example, OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 20 Classes and Objects contd..
  • 21.
    Now, Can you tellthe difference between a class and an object? OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 21 Classes and Objects contd..
  • 22.
    Procedural vs. OOPProgramming  Procedural Programming views a problem or situation in terms of procedures and then the data that procedures use.  OO Programming views a problem in terms of objects involved as the objects themselves take care of data involved (through characteristics) and procedures involved (through behaviour). OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 22
  • 23.
    Procedural vs. OOPProgramming Let us simulate traffic flow at a red light crossing.  Using procedural programming paradigm, the above said problem will be viewed in terms of working happening in the traffic-flow i.e., moving, accelerating, halting, turning etc.  The OOP paradigm, however, aims at the objects and their interface. Thus in OOP approach, the traffic-flow problem will be viewed in terms of the objects involved. The objects involved are : cars, trucks, buses, scooters, auto-rickshaws, taxis etc. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 23
  • 24.
    Let us Revisenow  Programming started with 1st Generation Language Machine language which is comprised of 0s and 1s i.e. Binary Language.  2nd Generation Language was Assembly Language which comprises of codes called Mnemonics for instructions.  First two generations of languages are called Low-level Languages.  3rd Generation Languages were High Level Languages(HLL) that have instructions as English Like and are easier to read, understand and debug. Examples include Fortran, Basic, C, Pascal, COBOL etc.  4th Generation Languages are non-procedural e.g. SQL.  5th Generation Languages are Artificial Intelligence compatible. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 24
  • 25.
    Let us Revisenow  Programming Paradigm means ‘way of writing a program’.  In Procedural Programming paradigm, procedure is more important, that is, instructions telling how to do a thing but the data get ignored.  In Modular Programming Paradigm, a big procedure of procedural paradigm is broken down in smaller modules.  Procedural and Modular paradigms do not model the real world well.  Object Oriented Programming paradigm designs a solution by considering the objects involved in the problem.  An Object is an identifiable entity with some characteristics and behaviour.  A Class is a template/blueprint representing a group of objects that share common properties and relationships. OOPS MAIN MENU Click Right Arrow and Left arrow buttons to navigate to next and previous screens respectively. 25