0% found this document useful (0 votes)
6 views29 pages

Module 1 Section 2

OPERATING MODEL 1

Uploaded by

vmickey4522
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)
6 views29 pages

Module 1 Section 2

OPERATING MODEL 1

Uploaded by

vmickey4522
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/ 29

Basic Concepts of OOP

Presented by:
Dr. Vinod Jain
Assistant Professor
Dept. Of CE&A
Basic Concepts of OOPs
• Object
• Class
• Encapsulation
• Abstraction
• Inheritance
• Polymorphism
• Dynamic Binding
• Message Passing
<Subject Code> <Name of Subject> 2
Object and Class

<Subject Code> <Name of Subject> 3


Basic Concepts of OOPs
Object: -
• Objects are the basic runtime entities
• They represent a place, bank account, a table of data or
any item
• Object contains data and code to manipulate the data
• Object take up space in the memory and have an
associated address
• the object interacts by sending message to one another.
Example: - If “Customer” and “account” are the two objects in a
program than customer object may send a message to account
object requesting for bank balance.

<BCAC0007> <Object Oriented Programming> 4


Basic Concepts of OOPs
CLASS: -
• Classes is a new way of creating and implementing the
user defined data type.
• It is a logical entity. A class serves as a plan or templates
• It specifies what data and what functions will be included
in object of that class.
• Objects are variable of the type class. Once the class has
been defined, we can create any number of objects
belonging to that class
• A class is thus a collection of objects of similar type.

<BCAC0007> <Object Oriented Programming> 5


<Subject Code> <Name of Subject> 6
Basic Concepts of OOPs
ENCAPSULATION: -
• The wrapping up of data and functions into a single unit
is known as Encapsulation.
• The data is not accessible to the outside world and only
those functions which are wrapped in the class can
access it .
• These functions provide the interface b/w the object
data and the program.
• So this insulation of the data from being direct access by
the program is called data hiding/ Information hiding.

<BCAC0007> <Object Oriented Programming> 7


<Subject Code> <Name of Subject> 8
Basic Concepts of OOPs
• Data Hiding
• A class has two sections namely private and public.
• The mechanism used to hide data is to put it in private
section of the class.
• Usually, the data within a class is declared in private section &
the functions are in public section. So the data is hidden from
outside world.
• The private data is only accessible to functions of the class.

<Subject Code> <Name of Subject> 9


ABSTRACTION

<BCAC0007> <Object Oriented Programming> 10


ABSTRACTION
ABSTRACTION: -
• It refers to the act of representing essential features without including the
background details/explanation. There are two types of abstraction in CPP
(C++).
1. Functional Abstraction: -
• It is known what the function does but not how it does. A programmer can
use existing functions without knowing their internal details.
2. Data Abstraction: -
• Data structures can be used without being concerned about the exact
details of implementation.
Example: - Floating point numbers are abstracted in programming
languages. We use float data type without knowing how it is represented
in binary form and we just assign value to them. In C++, we can define our
own data type (like classes). Since the classes use the concept of data
abstraction, they are known as abstract data type (ADT).

<BCAC0007> <Object Oriented Programming> 11


ABSTRACTION

<Subject Code> <Name of Subject> 12


Inheritance

<Subject Code> <Name of Subject> 13


Inheritance

<Subject Code> <Name of Subject> 14


INHERITANCE
• Using a concept called inheritance, a new class or
classes can be build from the old ones.
• The old class or original class is called as Base class.
• The new class is called as Derived class.

<BCAC0007> <Object Oriented Programming> 15


INHERITANCE
• Derived class inherits the data and functions of the
base class.
• The derived class can add data, elements and
functions to those it inherits from its base class.
• Real advantage of inheritance is that a programmer
can use an existing class i.e. almost what he wants
and to tailor the class in such a way that it does not
introduce any undesirable side effects into the rest of
the classes .
• The concept of inheritance provides the idea of re-
usability.
<BCAC0007> <Object Oriented Programming> 16
Polymorphism

<Subject Code> <Name of Subject> 17


Polymorphism

<Subject Code> <Name of Subject> 18


POLYMORPHISM
• The ability to take more than one form.
• It is the Greek word where “poly means many” and
“morphism means state/shape”.
• By polymorphism an operation may shows different behavior
in different instances.
• Polymorphism plays an important role in allowing objects
having different internal structure to share the same external-
internal phase.

<BCAC0007> <Object Oriented Programming> 19


POLYMORPHISM
• Examples of polymorphism
1. Operator Overloading
2. Function Overloading

<BCAC0007> <Object Oriented Programming> 20


POLYMORPHISM
• Operator overloading
• There are two numbers. If the numbers are integer than the
‘+’ operation will generate their sum.
• If the operands are strings than the ‘+’ operation would
reduce the third string by concatenation. This process of
making an operation to perform more than one operation is
called as “Operator overloading”.

<BCAC0007> <Object Oriented Programming> 21


POLYMORPHISM
• Function overloading
• A single function name can be used to handle different
numbers and different type of arguments.
• The function compute-area can be used to compute the area
of triangle, rectangle, and circle.
• Using a single function name to perform different type of
tasks is known as “function overloading”.
1. void print(int i)
2. void print(double f)

<BCAC0007> <Object Oriented Programming> 22


DYNAMIC BINDING

<BCAC0007> <Object Oriented Programming> 23


DYNAMIC BINDING
• Binding refers to a linking of a procedure call to the code to be
executed in response to the call. It is also known as Late
Binding.
• Dynamic binding means that the code associated with the
given procedure call is not known until the time of the call at
run time.

<BCAC0007> <Object Oriented Programming> 24


MESSAGE COMMUNICATION

<Subject Code> <Name of Subject> 25


Basic Concepts of OOPs
MESSAGE COMMUNICATION: -
• OOPs consist of a set of object that communicates with each other. So, it
involves following steps-
 Creating classes that define object and their behavior.
 Creating objects from class definition.
 Establishing communication among objects.

• Objects communicate with another through sending and receiving message. A


message for an object is a request for execution of a procedure and therefore
will invoke a function in the receiving objects that generates the desired
result.

Object name . function name (argument list)

object message information

<BCAC0007> <Object Oriented Programming> 26


Important Questions befor next
lecture I will ask
1. What is a class?
2. What is a object?
3. What is the difference between class and
object?
4. What is encapsulation?
5. What is data hiding?
6. What are private and public members in a
class?
<Subject Code> <Name of Subject> 27
Questions
• What is abstraction?
• What is inheritance?
• What are the benefits of inheritance?
• What is polymorphism?
• What are types of polymorphism ?

<Subject Code> <Name of Subject> 28


Thank you

<BCAC0007> <Object Oriented Programming> 29

You might also like