0% found this document useful (0 votes)
2 views14 pages

presentation one-oop

Object-oriented programming (OOP) is a programming paradigm centered around objects that have attributes and methods. Key concepts include classes, objects, encapsulation, abstraction, polymorphism, and inheritance, which facilitate data management and code reuse. The document also discusses the principles of encapsulation, types of polymorphism, and poses discussion questions on OOP's advantages, limitations, and comparisons with other programming paradigms.

Uploaded by

kakaismael
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)
2 views14 pages

presentation one-oop

Object-oriented programming (OOP) is a programming paradigm centered around objects that have attributes and methods. Key concepts include classes, objects, encapsulation, abstraction, polymorphism, and inheritance, which facilitate data management and code reuse. The document also discusses the principles of encapsulation, types of polymorphism, and poses discussion questions on OOP's advantages, limitations, and comparisons with other programming paradigms.

Uploaded by

kakaismael
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/ 14

OOP

• Object-oriented programming (OOP) is a style of programming that heavily


relies on objects. These objects can have attributes and methods. While
attributes store data, methods define behavior.
• There are some basic concepts that act as the building blocks of OOPs i.e.
➢Class
➢Object
➢Encapsulation
➢Abstraction
➢Polymorphism
➢Inheritance
What is a Class in Python?

OOP in Python heavily relies on the concept of class. You can think of a
class as a blueprint that is used to create objects. To illustrate this,
imagine that you have a blueprint for a speaker. You can use this
blueprint to build multiple speakers. Each speaker that is created using
the blueprint is an instance of the blueprint. Also, each created speaker
has its attributes such as color, model, and name. They will also have
their methods showing a certain kind of behavior such as volume up
and volume down.
Object

• An Object is an identifiable actual entity with some characteristics


and behavior. it is an instance of a class.
• When a class is defined, no memory is allocated but when it is
instantiated (i.e. an object is created) memory is allocated.
Abstraction

• Abstraction means displaying only essential information and ignoring


the other details. Data abstraction refers to providing only essential
information about the data to the outside world, hiding the
background details or implementation. It deals with what an object
does, not how it does it.
Example:
An alarm interface declares methods like start(), stop(). In this case, we
don’t care how they are implemented but we only care that they work.
Encapsulation
• This is defined as wrapping up data and methods that operate on that
data under a single unit (a class), and restricting direct access to some
components.
• This is done in order to protect an object’s internal state from
unintended interference
Key Principles of encapsulation:
1. Bundling data and methods: Combine related data and the methods
that operate on that data into one logical unit.(class)
Example: A student class bundles fields like name, regno,date-of-birth
and methods like Add_student(), Delete_student(), Modify_student()
e.t.c
2. Data Hiding: Restrict direct access to internal data by using access
modifiers.i.e
➢Private: Accessible only within the class
➢Protected: Accessible with in the class and subclasses
➢Public: Accessible everywhere
Example: In our previous student class, we can mark date-of-birth as
private to hide it from the external code.
3. Controlled access via methods: Expose public methods to interact
with private data.
Polymorphism

The word polymorphism means having many forms. In simple words,


we can define polymorphism as the ability of an entity(object)to
behave different in different scenarios.
For example, the same makeSound() method, the output will vary
depending on the type of animal. So, this is an example of
polymorphism where the makeSound() method behaves differently
depending on the Animal type (Dog or Cat).
polymorphism can be of three types:
1. Operator Overloading: This is the process of making an operator
exhibit different behavior in different instances
operator overloading refers to the practice of redefining the
functionality of operators for user-defined data types.
2. Function overloading: This is the process of having two or more
functions with the same name but with different parameters
(arguments)
3. Function Overriding: This is when a subclass provides its own
implementation of the method which is already defined in its
superclass. We can take an example of class Phone with subclasses
Techno,Redmi,Iphone e.t.c , with this, we can have a method called
Update-phone()
Inheritance

The capability of a class to derive properties and characteristics from


another class is called Inheritance.
• Sub Class: The class that inherits properties from another class is
called Sub class or Derived Class.
• Super Class: The class whose properties are inherited by a sub-class is
called Base Class or Superclass.
Discussion Questions

1. Explain the Differences Between Procedure Oriented Programming


(POP) & Object-Oriented Programming (OOP)
2. Explain the advantages and limitations of object-oriented
programming.
3. Explain the differences between inheritance and composition
4. Object-oriented languages provide three basic member access
modifiers. For each modifier, explain their purpose and describe
example scenarios to illustrate your answer. Your scenarios should
include both data members and functions.
5. Explain two different ways that object-oriented programming
languages promote code re-use that are not also found in procedural
languages.
Illustrate your answer with examples
6. Compare and contrast abstract and concrete classes making at least
five distinctions

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy