0% found this document useful (0 votes)
13 views10 pages

Ooplecture 2

The document discusses object oriented programming concepts like abstraction, encapsulation, inheritance and polymorphism. Abstraction and encapsulation hide internal implementation details and expose only necessary information to external programs. Inheritance allows classes to inherit properties from other classes. Polymorphism allows the same message to display in different forms based on context.

Uploaded by

islamshofi942
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)
13 views10 pages

Ooplecture 2

The document discusses object oriented programming concepts like abstraction, encapsulation, inheritance and polymorphism. Abstraction and encapsulation hide internal implementation details and expose only necessary information to external programs. Inheritance allows classes to inherit properties from other classes. Polymorphism allows the same message to display in different forms based on context.

Uploaded by

islamshofi942
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/ 10

CSE-207: OBJECT ORIENTED PROGRAMMING

Lecture 2: Introduction to OOP


Instructor:
Bipasha Majumder
Lecturer, Dept of CSE
Dhaka International University
Abstraction in OOPs

• Abstraction is the process of hiding the internal details of an application from


the outer world. Abstraction is used to describe things in simple terms. It’s used
to create a boundary between the application and the client programs.
• Abstraction is similar to data encapsulation and very important in OOP. It shows
only the necessary information and hides the other irrelevant information.
Abstraction is implemented using Abstraction classes and interfaces . The
problems in Abstraction are solved at design or interface level.
• Objects are the building blocks of Object-Oriented Programming. An object
contains some properties and methods. We can hide them from the outer world
through access modifiers. We can provide access only for required functions and
properties to the other programs. This is the general procedure to implement
abstraction in OOPS.
Real World Example --
Your automobile is an excellent
illustration of abstraction. Turning
the key or pressing the start button
is how you start a car. You don't
need to know how your car's engine
starts or what components it
contains. The user is completely
unaware of the car's internal
implementation and complicated
logic.
Encapsulation in OOPs
• Encapsulation is defined as the wrapping up of data under a single unit. It is the
mechanism that binds together code and the data it manipulates. In
Encapsulation, the variables or data of a class are hidden from any other class
and can be accessed only through any member function of their class in which
they are declared. As in encapsulation, the data in a class is hidden from other
classes, so it is also known as data-hiding.
Real World Example --
Consider a real-life example of encapsulation, in a company, there are different
sections like the accounts section, finance section, sales section, etc. The finance
section handles all the financial transactions and keeps records of all the data
related to finance. Similarly, the sales section handles all the sales-related
activities and keeps records of all the sales. Now there may arise a situation when
for some reason an official from the finance section needs all the data about sales
in a particular month. In this case, he is not allowed to directly access the data of
the sales section. He will first have to contact some other officer in the sales
section and then request him to give the particular data. This is what
encapsulation is. Here the data of the sales section and the employees that can
manipulate them are wrapped under a single name “sales section”.
Inheritance in OOPs

• Inheritance is an important pillar of OOP(Object-Oriented


Programming). The capability of a class to derive properties and
characteristics from another class is called Inheritance. When we
write a class, we inherit properties from other classes. So when we
create a class, we do not need to write all the properties and
functions again and again, as these can be inherited from another
class that possesses it. Inheritance allows the user to reuse the code
whenever possible and reduce its redundancy.
Real World Example --
As we can see in the image, a child
inherits the properties from his
father. Similarly, in inheritance, there
are two classes:

1. Parent class ( Super or Base class)


2. Child class (Subclass or Derived
class )
A class which inherits the properties
is known as Child Class whereas a
class whose properties are inherited
is known as Parent class.
Polymorphism in OOPs

• The word polymorphism means having many forms. In simple words, we can
define polymorphism as the ability of a message to be displayed in more than
one form. For example, A person at the same time can have different
characteristics. Like a man at the same time is a father, a husband, an employee.
So the same person posses different behavior in different situations. This is
called polymorphism.
Real World Example --
Suppose if you are in a
classroom at that time you
behave like a student, when
you are in the market at that
time you behave like
a customer when you at your
home at that time you behave
like a son or daughter, Here
one person present in
different-different behaviors.
Thank you

You might also like