SlideShare a Scribd company logo
CHAPTER - 04
OBJECT ORIENTED PROGRAMMING
Unit I
Programming and Computational
Thinking (PCT-2)
(80 Theory + 70 Practical)
DCSc & Engg, PGDCA,ADCA,MCA.MSc(IT),Mtech(IT),MPhil (Comp. Sci)
Department of Computer Science, Sainik School Amaravathinagar
Cell No: 9431453730
Praveen M Jigajinni
Prepared by
Courtesy CBSE
Class XII
INTRODUCTION
INTRODUCTION
An object-oriented programming (OOP) is a
programming language model which is organized
around "objects" rather than "actions" and data
rather than logic. Before the introduction of the
Object Oriented
Programming paradigm, a program was viewed
as a logical procedure that takes input data,
processes it, and produces output. But in case of
OOP a problem is viewed in terms of objects rather
than procedure for doing it.
BASIC CONCEPTS OF OBJECT ORIENTED
PROGRAMMING
The basic concepts related to OOP are as
follows:
1. Objects
2. Classes
3. Encapsulation
4. Abstraction
5. Data Hiding
6. Polymorphism
7. Inheritance
BASIC CONCEPTS OF OBJECT ORIENTED
PROGRAMMING
1. Objects
An object is the basic key concept of
Object Oriented Programming. it can be anything
around us - a person, place, any activity or any other
identifiable entity. Every object is characterised by
i) identity ii) Properties iii) Behaviour
i. Identity : This is the name that identifies an
object.
For example a Student is the name given to anybody
who is pursuing a course
BASIC CONCEPTS OF OBJECT ORIENTED
PROGRAMMING
ii. Properties: These are the features or attributes of
the object
For example a student will have his name, age, class,
date of birth etc. as his attributes or properties.
iii. Behaviour: The behaviour of an object signifies
what all functions an object can perform.
For example a student can pass or fail the
examination. A mobile phone can click and store
photographs (behave like a camera).
BASIC CONCEPTS OF OBJECT ORIENTED
PROGRAMMING
What is Class?
A class is group of objects with same
attributes and common behaviours. It is
basically a blueprint to create objects. An
object is a basic key concept of OOP but
classes provide an ability to generalize similar
type of objects. Both data and functions
operating on the data are bundled as a unit in
a class for the same category of objects.
BASIC CONCEPTS OF OBJECT ORIENTED
PROGRAMMING
for example of the class Mobile_phone
which is represented in the block diagram
below
BASIC CONCEPTS OF OBJECT ORIENTED
PROGRAMMING
A class is defined before the creation of objects of
its type. The objects are then created as instances of
this class as shown in the figure.
BASIC CONCEPTS OF OBJECT ORIENTED
PROGRAMMING
A class is defined before the creation of objects of
its type. The objects are then created as instances of
this class as shown in the figure.
BASIC CONCEPTS OF OBJECT ORIENTED
PROGRAMMING
OBJECTS
A real instance of a class is called an object and
creating the new object is called instantiation.
BASIC CONCEPTS OF OBJECT ORIENTED
PROGRAMMING
WHAT IS INSTANTIATION?
OOP FEATURES
Encapsulation
Data Hiding
Data Abstraction
Inheritance
Polymorphism
OOP FEATURES
Encapsulation
Encapsulation is the most basic concept of
OOP. It is the combining of data and the functions
associated with that data in a single unit. In most of
the languages including python, this unit is called a
class. In Fig showing class Mobile_phone, given
under the subtopic Classes, we see that the name of
the class, its properties or attributes and behaviours
are all enclosed under one independent unit. This is
encapsulation, implemented through the unit
named class.
OOP FEATURES
Data Hiding
Data hiding can be defined as the mechanism of
hiding the data of a class from the outside world
or to be precise, from other classes. This is done
to protect the data from any accidental or
intentional access.
In most of the object oriented programming
languages, encapsulation is implemented through
classes. In a class, data may be made private or
public.
OOP FEATURES
Data Hiding
Private data or function of a class cannot be
accessed from outside the class while public data
or functions can be accessed from anywhere. So
data hiding is achieved by making the members of
the class private. Access to private members is
restricted and is only available to the member
functions of the same class.
OOP FEATURES
Data Abstraction
Do you know the inner details of the
monitor of your PC or your mobile phone? What
happens when you switch ON the monitor or
when any call is received by you on your phone?
Does it really matter to you what is happening
inside these devices? No, it does not. Right?
Important thing for you is whether these devices
are working as per your requirement or not?
OOP FEATURES
Data Abstraction
You are never concerned about their inner
circuitry. This is what we call abstraction.
The process of identifying and separating
the essential features without including the
internal details is abstraction.
Only the essential information is
provided to the outside world while the
background details are hidden.
OOP FEATURES
Data Abstraction
Classes use the concept of abstraction. A
class encapsulates the relevant data and functions
that operate on data by hiding the complex
implementation details from the user. The user
needs to focus on what a class does rather than
how it does.
OOP FEATURES
Data Abstraction
Abstraction and Encapsulation are
complementary concepts. Through encapsulation
only we are able to enclose the components of the
object into a single unit and separate the private
and public members. It is through abstraction that
only the essential behaviours of the objects are
made visible to the outside world.
So we can say that encapsulation is the way
to implement data abstraction.
OOP FEATURES
Inheritance
Inheritance is one of the most useful
characteristic of object-oriented programming as
it enforces reusability of code. Inheritance is the
process of forming a new class (derived class)
from an existing class (called the base class). The
data members and the methods associated with
the data are accessible in the inherited class.
OOP FEATURES
Inheritance
OOP FEATURES
Polymorphism
The word Polymorphism is formed from two words
- poly and morph where poly means many and
morph means forms. So polymorphism is the
ability to use an operator or function in various
forms. That is a single function or an operator
behaves differently depending upon the data
provided to them. Polymorphism can be achieved
in two ways:
OOP FEATURES
Polymorphism
Polymorphism can be achieved in two ways:
1. Operator Overloading
2. Function Overloading
OOP FEATURES
Polymorphism
1. Operator Overloading: The '+' operator behaves
differently with different data types. With integers it
adds the two numbers and with strings it
concatenates or joins two strings. For example:
Print 8+9 will give 17 and
Print "Python" + "programming" will give the output
as Pythonprogramming.
This feature where an operator can be used in
different forms is known as Operator Overloading and
is one of the methods to implement polymorphism.
OOP FEATURES
Polymorphism
2. Function Overloading:
Polymorphism in case of functions is a bit
different. A named function can also vary
depending on the parameters it is given. For
example, we define multiple functions with same
name but different argument list as shown below:
OOP FEATURES
Polymorphism
def test(): #function 1
print "hello"
def test(a, b): #function 2
return a+b
def test(a, b, c): #function 3
return a+b+c
Static and Dynamic Binding
Binding is the process of linking the
function call to the function definition. The
body of the function is executed when the
function call is made. Binding can be of two
types:
1. Static Binding.
2. Dynamic Binding.
Static Binding
In this type of binding, the linking of
function call to the function definition is
done during compilation of the program.
Dynamic Binding
In this type of binding, linking of a
function call to the function definition is
done at run time. That means the code of
the function that is to be linked with
function call is unknown until it is executed.
Dynamic binding of functions makes the
programs more flexible.
Advantages of OOP
Object Oriented programming has
following advantages:
1. Simplicity.
2. Modifiability.
3. Extensibility and Maintainability.
4. Re-usability.
5. Security.
Advantages of OOP
The objects in case of OOP are close to
the real world objects, so the complexity of
the program is reduced making the program
structure very clear and simple. For example
by looking at the class Mobile_phone, you
can simply identify with the properties and
behaviour of an actual mobile phone. This
makes the class Mobile_phone very simple
and easy to understand.
1. Simplicity
Advantages of OOP
It is easy to make minor changes in
the data representation or the procedures in
an OO
program. Changes inside a class do not
affect any other part of a program, since the
only public
interface that the external world has to a
class is through the use of methods.
2. Modifiability
Advantages of OOP
It is quite easy to add new features
and extend the program in case of object
oriented programming. It can be simply
done by introducing a few new objects and
modifying some existing ones. The original
base class need not be modified at all. Even
objects can be maintained separately. There
by making locating and fixing problems
easier.
3. Extensibility and Maintainability
Advantages of OOP
For example if a new version of i-
phone is introduced, a new derived class of
the class i_phone for the new version may
be created and no other class in the class
hierarchy need to be modified. Similarly if
any behaviour of a Windows phone
changes, maintenance has to be done only
for the class Windows phone
3. Extensibility and Maintainability
Advantages of OOP
Objects can be reused in different
programs. The class definitions can be
reused in various applications. Inheritance
makes it possible to define subclasses of
data objects that share some or all of the
main class characteristics. It forces a more
thorough data analysis, reduces
development time, and ensures more
accurate coding.
4. Re-usability
Advantages of OOP
Since a class defines only the data it
needs to be concerned with, when an
instance of that class (an object) is run, the
code will not be able to accidentally access
other program data. This characteristic of
data hiding provides greater system security
and avoids unintended data corruption.
5. Security
CLASS TEST
1. Explain in detail the object oriented
programming
2. What is polymorphism? Explain
3. Explain Data Abstraction
4. What is Data Hiding?
5. Explain in detail static and dynamic binding
Class : XII Time: 40 Min
Topic: OOPS Max Marks: 20
Each Question carries 5 marks
Thank You

More Related Content

PPTX
Python Functions
Mohammed Sikander
 
PPT
Oops ppt
abhayjuneja
 
PPTX
Applications of Machine Learning
Hayim Makabee
 
PDF
Python Class | Python Programming | Python Tutorial | Edureka
Edureka!
 
PPTX
Tokens in C++
Mahender Boda
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PDF
Classification Based Machine Learning Algorithms
Md. Main Uddin Rony
 
PPTX
WHAT IS ABSTRACTION IN JAVA
sivasundari6
 
Python Functions
Mohammed Sikander
 
Oops ppt
abhayjuneja
 
Applications of Machine Learning
Hayim Makabee
 
Python Class | Python Programming | Python Tutorial | Edureka
Edureka!
 
Tokens in C++
Mahender Boda
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Classification Based Machine Learning Algorithms
Md. Main Uddin Rony
 
WHAT IS ABSTRACTION IN JAVA
sivasundari6
 

What's hot (20)

PPT
enums
teach4uin
 
PDF
Data science syllabus
anoop bk
 
PPTX
Classification Algorithm.
Megha Sharma
 
PPTX
Learning in AI
Minakshi Atre
 
PPSX
python Function
Ronak Rathi
 
PDF
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
PPTX
Finite automata-for-lexical-analysis
Dattatray Gandhmal
 
PPTX
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
PPTX
K-Nearest Neighbor Classifier
Neha Kulkarni
 
PPTX
Templates and Exception Handling in C++
Nimrita Koul
 
PPTX
Applets in java
Wani Zahoor
 
PPTX
Java Data Types
Spotle.ai
 
PPTX
Scikit Learn intro
9xdot
 
PPTX
Regular expressions in Python
Sujith Kumar
 
PPT
ADO .Net
DrSonali Vyas
 
PDF
Enumeration in Java Explained | Java Tutorial | Edureka
Edureka!
 
PPT
Chapter8
akhila chilukuri
 
PDF
Supervised and Unsupervised Machine Learning
Spotle.ai
 
PPT
Java Notes
Abhishek Khune
 
enums
teach4uin
 
Data science syllabus
anoop bk
 
Classification Algorithm.
Megha Sharma
 
Learning in AI
Minakshi Atre
 
python Function
Ronak Rathi
 
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
Finite automata-for-lexical-analysis
Dattatray Gandhmal
 
Python-Inheritance.pptx
Karudaiyar Ganapathy
 
K-Nearest Neighbor Classifier
Neha Kulkarni
 
Templates and Exception Handling in C++
Nimrita Koul
 
Applets in java
Wani Zahoor
 
Java Data Types
Spotle.ai
 
Scikit Learn intro
9xdot
 
Regular expressions in Python
Sujith Kumar
 
ADO .Net
DrSonali Vyas
 
Enumeration in Java Explained | Java Tutorial | Edureka
Edureka!
 
Supervised and Unsupervised Machine Learning
Spotle.ai
 
Java Notes
Abhishek Khune
 
Ad

Similar to Chapter 04 object oriented programming (20)

DOCX
Benefits of encapsulation
Muhammad Nawzir Khan
 
PDF
C++ & VISUAL C++
Makaha Rutendo
 
PDF
Object Oriented Programming With C 2140705 Darshan All Unit Darshan Institute...
hslinaaltosh
 
PPTX
basics of c++ object oriented programming l anguage
farooqabubakar4000
 
PPTX
introduction to object oriented programming
farooqabubakar4000
 
PDF
OOPS_Unit_1
Shipra Swati
 
PPTX
1 intro
abha48
 
PPTX
OBJECT ORIENTED PROGRAMMING CONCEPTS IN C++.pptx
Maharshi Dayanand University Rohtak
 
PPTX
POP vs OOP Introduction
Hashni T
 
PPTX
OOP.pptx
kalyanibedekar
 
PDF
MCA NOTES.pdf
RAJASEKHARV10
 
DOC
Chapter1
jammiashok123
 
PPTX
Basics of object oriented programming c++ [autosaved]
RAVIPUROHIT22
 
PPTX
Chapter1 introduction
Jeevan Acharya
 
PDF
Computer_Programming_Part_II_Segment_01.pdf
et243047
 
PDF
CS305PC_C++_UNIT 1 notes jntuh third semester
VeeraswamyDasari2
 
DOCX
Object Oriented Programming All Unit Notes
BalamuruganV28
 
PPTX
Object Oriented Programming using c++ main four piller in this
vidhimangal05
 
PPTX
Object Oriented Programming.pptx its a opps concept in c++ which is helpful
vidhimangal05
 
PDF
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
Benefits of encapsulation
Muhammad Nawzir Khan
 
C++ & VISUAL C++
Makaha Rutendo
 
Object Oriented Programming With C 2140705 Darshan All Unit Darshan Institute...
hslinaaltosh
 
basics of c++ object oriented programming l anguage
farooqabubakar4000
 
introduction to object oriented programming
farooqabubakar4000
 
OOPS_Unit_1
Shipra Swati
 
1 intro
abha48
 
OBJECT ORIENTED PROGRAMMING CONCEPTS IN C++.pptx
Maharshi Dayanand University Rohtak
 
POP vs OOP Introduction
Hashni T
 
OOP.pptx
kalyanibedekar
 
MCA NOTES.pdf
RAJASEKHARV10
 
Chapter1
jammiashok123
 
Basics of object oriented programming c++ [autosaved]
RAVIPUROHIT22
 
Chapter1 introduction
Jeevan Acharya
 
Computer_Programming_Part_II_Segment_01.pdf
et243047
 
CS305PC_C++_UNIT 1 notes jntuh third semester
VeeraswamyDasari2
 
Object Oriented Programming All Unit Notes
BalamuruganV28
 
Object Oriented Programming using c++ main four piller in this
vidhimangal05
 
Object Oriented Programming.pptx its a opps concept in c++ which is helpful
vidhimangal05
 
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
Ad

More from Praveen M Jigajinni (20)

PPTX
Chapter 09 design and analysis of algorithms
Praveen M Jigajinni
 
PPTX
Chapter 08 data file handling
Praveen M Jigajinni
 
PPTX
Chapter 07 inheritance
Praveen M Jigajinni
 
PPTX
Chapter 06 constructors and destructors
Praveen M Jigajinni
 
PPTX
Chapter 05 classes and objects
Praveen M Jigajinni
 
PPTX
Chapter 03 python libraries
Praveen M Jigajinni
 
PPTX
Chapter 02 functions -class xii
Praveen M Jigajinni
 
PPTX
Unit 3 MongDB
Praveen M Jigajinni
 
PPTX
Chapter 17 Tuples
Praveen M Jigajinni
 
PPTX
Chapter 15 Lists
Praveen M Jigajinni
 
PPTX
Chapter 14 strings
Praveen M Jigajinni
 
PPTX
Chapter 13 exceptional handling
Praveen M Jigajinni
 
PPTX
Chapter 10 data handling
Praveen M Jigajinni
 
PPTX
Chapter 9 python fundamentals
Praveen M Jigajinni
 
PPTX
Chapter 8 getting started with python
Praveen M Jigajinni
 
PPTX
Chapter 7 basics of computational thinking
Praveen M Jigajinni
 
PPTX
Chapter 6 algorithms and flow charts
Praveen M Jigajinni
 
PPTX
Chapter 5 boolean algebra
Praveen M Jigajinni
 
PPTX
Chapter 4 number system
Praveen M Jigajinni
 
PPTX
Chapter 3 cloud computing and intro parrallel computing
Praveen M Jigajinni
 
Chapter 09 design and analysis of algorithms
Praveen M Jigajinni
 
Chapter 08 data file handling
Praveen M Jigajinni
 
Chapter 07 inheritance
Praveen M Jigajinni
 
Chapter 06 constructors and destructors
Praveen M Jigajinni
 
Chapter 05 classes and objects
Praveen M Jigajinni
 
Chapter 03 python libraries
Praveen M Jigajinni
 
Chapter 02 functions -class xii
Praveen M Jigajinni
 
Unit 3 MongDB
Praveen M Jigajinni
 
Chapter 17 Tuples
Praveen M Jigajinni
 
Chapter 15 Lists
Praveen M Jigajinni
 
Chapter 14 strings
Praveen M Jigajinni
 
Chapter 13 exceptional handling
Praveen M Jigajinni
 
Chapter 10 data handling
Praveen M Jigajinni
 
Chapter 9 python fundamentals
Praveen M Jigajinni
 
Chapter 8 getting started with python
Praveen M Jigajinni
 
Chapter 7 basics of computational thinking
Praveen M Jigajinni
 
Chapter 6 algorithms and flow charts
Praveen M Jigajinni
 
Chapter 5 boolean algebra
Praveen M Jigajinni
 
Chapter 4 number system
Praveen M Jigajinni
 
Chapter 3 cloud computing and intro parrallel computing
Praveen M Jigajinni
 

Recently uploaded (20)

PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PDF
5.EXPLORING-FORCES-Detailed-Notes.pdf/8TH CLASS SCIENCE CURIOSITY
Sandeep Swamy
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Sunset Boulevard Student Revision Booklet
jpinnuck
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPT
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
5.EXPLORING-FORCES-Detailed-Notes.pdf/8TH CLASS SCIENCE CURIOSITY
Sandeep Swamy
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Sunset Boulevard Student Revision Booklet
jpinnuck
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Python Programming Unit II Control Statements.ppt
CUO VEERANAN VEERANAN
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
7.Particulate-Nature-of-Matter.ppt/8th class science curiosity/by k sandeep s...
Sandeep Swamy
 

Chapter 04 object oriented programming

  • 1. CHAPTER - 04 OBJECT ORIENTED PROGRAMMING
  • 2. Unit I Programming and Computational Thinking (PCT-2) (80 Theory + 70 Practical) DCSc & Engg, PGDCA,ADCA,MCA.MSc(IT),Mtech(IT),MPhil (Comp. Sci) Department of Computer Science, Sainik School Amaravathinagar Cell No: 9431453730 Praveen M Jigajinni Prepared by Courtesy CBSE Class XII
  • 4. INTRODUCTION An object-oriented programming (OOP) is a programming language model which is organized around "objects" rather than "actions" and data rather than logic. Before the introduction of the Object Oriented Programming paradigm, a program was viewed as a logical procedure that takes input data, processes it, and produces output. But in case of OOP a problem is viewed in terms of objects rather than procedure for doing it.
  • 5. BASIC CONCEPTS OF OBJECT ORIENTED PROGRAMMING
  • 6. The basic concepts related to OOP are as follows: 1. Objects 2. Classes 3. Encapsulation 4. Abstraction 5. Data Hiding 6. Polymorphism 7. Inheritance BASIC CONCEPTS OF OBJECT ORIENTED PROGRAMMING
  • 7. 1. Objects An object is the basic key concept of Object Oriented Programming. it can be anything around us - a person, place, any activity or any other identifiable entity. Every object is characterised by i) identity ii) Properties iii) Behaviour i. Identity : This is the name that identifies an object. For example a Student is the name given to anybody who is pursuing a course BASIC CONCEPTS OF OBJECT ORIENTED PROGRAMMING
  • 8. ii. Properties: These are the features or attributes of the object For example a student will have his name, age, class, date of birth etc. as his attributes or properties. iii. Behaviour: The behaviour of an object signifies what all functions an object can perform. For example a student can pass or fail the examination. A mobile phone can click and store photographs (behave like a camera). BASIC CONCEPTS OF OBJECT ORIENTED PROGRAMMING
  • 9. What is Class? A class is group of objects with same attributes and common behaviours. It is basically a blueprint to create objects. An object is a basic key concept of OOP but classes provide an ability to generalize similar type of objects. Both data and functions operating on the data are bundled as a unit in a class for the same category of objects. BASIC CONCEPTS OF OBJECT ORIENTED PROGRAMMING
  • 10. for example of the class Mobile_phone which is represented in the block diagram below BASIC CONCEPTS OF OBJECT ORIENTED PROGRAMMING
  • 11. A class is defined before the creation of objects of its type. The objects are then created as instances of this class as shown in the figure. BASIC CONCEPTS OF OBJECT ORIENTED PROGRAMMING
  • 12. A class is defined before the creation of objects of its type. The objects are then created as instances of this class as shown in the figure. BASIC CONCEPTS OF OBJECT ORIENTED PROGRAMMING OBJECTS
  • 13. A real instance of a class is called an object and creating the new object is called instantiation. BASIC CONCEPTS OF OBJECT ORIENTED PROGRAMMING WHAT IS INSTANTIATION?
  • 14. OOP FEATURES Encapsulation Data Hiding Data Abstraction Inheritance Polymorphism
  • 15. OOP FEATURES Encapsulation Encapsulation is the most basic concept of OOP. It is the combining of data and the functions associated with that data in a single unit. In most of the languages including python, this unit is called a class. In Fig showing class Mobile_phone, given under the subtopic Classes, we see that the name of the class, its properties or attributes and behaviours are all enclosed under one independent unit. This is encapsulation, implemented through the unit named class.
  • 16. OOP FEATURES Data Hiding Data hiding can be defined as the mechanism of hiding the data of a class from the outside world or to be precise, from other classes. This is done to protect the data from any accidental or intentional access. In most of the object oriented programming languages, encapsulation is implemented through classes. In a class, data may be made private or public.
  • 17. OOP FEATURES Data Hiding Private data or function of a class cannot be accessed from outside the class while public data or functions can be accessed from anywhere. So data hiding is achieved by making the members of the class private. Access to private members is restricted and is only available to the member functions of the same class.
  • 18. OOP FEATURES Data Abstraction Do you know the inner details of the monitor of your PC or your mobile phone? What happens when you switch ON the monitor or when any call is received by you on your phone? Does it really matter to you what is happening inside these devices? No, it does not. Right? Important thing for you is whether these devices are working as per your requirement or not?
  • 19. OOP FEATURES Data Abstraction You are never concerned about their inner circuitry. This is what we call abstraction. The process of identifying and separating the essential features without including the internal details is abstraction. Only the essential information is provided to the outside world while the background details are hidden.
  • 20. OOP FEATURES Data Abstraction Classes use the concept of abstraction. A class encapsulates the relevant data and functions that operate on data by hiding the complex implementation details from the user. The user needs to focus on what a class does rather than how it does.
  • 21. OOP FEATURES Data Abstraction Abstraction and Encapsulation are complementary concepts. Through encapsulation only we are able to enclose the components of the object into a single unit and separate the private and public members. It is through abstraction that only the essential behaviours of the objects are made visible to the outside world. So we can say that encapsulation is the way to implement data abstraction.
  • 22. OOP FEATURES Inheritance Inheritance is one of the most useful characteristic of object-oriented programming as it enforces reusability of code. Inheritance is the process of forming a new class (derived class) from an existing class (called the base class). The data members and the methods associated with the data are accessible in the inherited class.
  • 24. OOP FEATURES Polymorphism The word Polymorphism is formed from two words - poly and morph where poly means many and morph means forms. So polymorphism is the ability to use an operator or function in various forms. That is a single function or an operator behaves differently depending upon the data provided to them. Polymorphism can be achieved in two ways:
  • 25. OOP FEATURES Polymorphism Polymorphism can be achieved in two ways: 1. Operator Overloading 2. Function Overloading
  • 26. OOP FEATURES Polymorphism 1. Operator Overloading: The '+' operator behaves differently with different data types. With integers it adds the two numbers and with strings it concatenates or joins two strings. For example: Print 8+9 will give 17 and Print "Python" + "programming" will give the output as Pythonprogramming. This feature where an operator can be used in different forms is known as Operator Overloading and is one of the methods to implement polymorphism.
  • 27. OOP FEATURES Polymorphism 2. Function Overloading: Polymorphism in case of functions is a bit different. A named function can also vary depending on the parameters it is given. For example, we define multiple functions with same name but different argument list as shown below:
  • 28. OOP FEATURES Polymorphism def test(): #function 1 print "hello" def test(a, b): #function 2 return a+b def test(a, b, c): #function 3 return a+b+c
  • 29. Static and Dynamic Binding Binding is the process of linking the function call to the function definition. The body of the function is executed when the function call is made. Binding can be of two types: 1. Static Binding. 2. Dynamic Binding.
  • 30. Static Binding In this type of binding, the linking of function call to the function definition is done during compilation of the program.
  • 31. Dynamic Binding In this type of binding, linking of a function call to the function definition is done at run time. That means the code of the function that is to be linked with function call is unknown until it is executed. Dynamic binding of functions makes the programs more flexible.
  • 32. Advantages of OOP Object Oriented programming has following advantages: 1. Simplicity. 2. Modifiability. 3. Extensibility and Maintainability. 4. Re-usability. 5. Security.
  • 33. Advantages of OOP The objects in case of OOP are close to the real world objects, so the complexity of the program is reduced making the program structure very clear and simple. For example by looking at the class Mobile_phone, you can simply identify with the properties and behaviour of an actual mobile phone. This makes the class Mobile_phone very simple and easy to understand. 1. Simplicity
  • 34. Advantages of OOP It is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods. 2. Modifiability
  • 35. Advantages of OOP It is quite easy to add new features and extend the program in case of object oriented programming. It can be simply done by introducing a few new objects and modifying some existing ones. The original base class need not be modified at all. Even objects can be maintained separately. There by making locating and fixing problems easier. 3. Extensibility and Maintainability
  • 36. Advantages of OOP For example if a new version of i- phone is introduced, a new derived class of the class i_phone for the new version may be created and no other class in the class hierarchy need to be modified. Similarly if any behaviour of a Windows phone changes, maintenance has to be done only for the class Windows phone 3. Extensibility and Maintainability
  • 37. Advantages of OOP Objects can be reused in different programs. The class definitions can be reused in various applications. Inheritance makes it possible to define subclasses of data objects that share some or all of the main class characteristics. It forces a more thorough data analysis, reduces development time, and ensures more accurate coding. 4. Re-usability
  • 38. Advantages of OOP Since a class defines only the data it needs to be concerned with, when an instance of that class (an object) is run, the code will not be able to accidentally access other program data. This characteristic of data hiding provides greater system security and avoids unintended data corruption. 5. Security
  • 39. CLASS TEST 1. Explain in detail the object oriented programming 2. What is polymorphism? Explain 3. Explain Data Abstraction 4. What is Data Hiding? 5. Explain in detail static and dynamic binding Class : XII Time: 40 Min Topic: OOPS Max Marks: 20 Each Question carries 5 marks