0% found this document useful (0 votes)
14 views

Module2 - OOP

Uploaded by

ayomikun569
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)
14 views

Module2 - OOP

Uploaded by

ayomikun569
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/ 13

COMPUTER PROGRAMMING I

Object Oriented Programming Concepts

COURSE CODE:
(COS201)

COURSE LECTURERS

1 Dr. Olaniyan Deborah


2 Dr. Julius Olaniyan

First Semester
2024/2025 Session
OUTLINE
 Object-Oriented Programming Concepts:

 Classes
 Objects
 Methods
 Encapsulation
 Inheritance
 Polymorphism

 Second Assignment
2
OOP CONCEPTS
 Object-Oriented Programming (OOP) is a
programming paradigm that organizes software
design around objects rather than functions and
logic.
 An object can be defined as a collection of data
(attributes or properties) and methods (functions or
behaviors) that act on the data.
 In OOP, the focus is on creating reusable objects that
interact with each other to solve problems.
 This approach models real-world entities as software
objects with characteristics (data) and capabilities
(methods). 3
KEY CONCEPTS OF OOP
 Classes: Blueprints or templates for creating objects. They define the properties (attributes) and

methods (behaviors) that the objects will have.

 Objects: Instances of classes that contain real data and can perform actions using the methods

defined in the class.

 Encapsulation: The bundling of data and methods into a single unit (class), restricting direct

access to some of an object's components and providing controlled access through methods.

 Inheritance: A mechanism where one class can inherit attributes and methods from another

class, promoting code reuse and hierarchical relationships.

 Polymorphism: The ability to process objects differently based on their data type or class. It

allows one interface to be used for different data types.

 Abstraction: Hiding the complexity of the system and exposing only the essential features, 4
simplifying the interaction between objects.
ADVANTAGES OF OOP
 Modularity:
 Code is organized into classes and objects, making it easier to manage,
modify, and debug.
 Reusability:
 Through inheritance, code can be reused, reducing redundancy.
 Flexibility:
 Polymorphism and encapsulation enable flexible and maintainable code
that adapts easily to changes.
 Scalability:
 OOP makes it easier to manage larger, more complex software systems by
breaking them into smaller, manageable components.
5
KEY CONCEPTS OF OOP
 A class is a blueprint or template for creating
objects.

 It defines the properties (attributes/states) and


behaviors (methods) that an object can have.

 A class encapsulates data for the object and


methods to manipulate that data.
6
KEY CONCEPTS OF OOP
A method is a function defined within a
class.

 It
describes the behavior of objects
created from the class.

 Methods can accept parameters, return 7

values, and perform actions.


KEY CONCEPTS OF OOP
 Encapsulation is the concept of wrapping data
(variables) and code (methods) into a single unit, i.e.,
the class.
 Encapsulation also involves restricting direct access to
some of an object's components and only exposing
necessary details.

8
KEY CONCEPTS OF OOP
 Inheritance is a mechanism that allows a new class
to inherit the properties and behaviors of an existing
class.

 The new class is called the subclass or child class,


and the existing class is called the superclass or
parent class.

9
POLYMORPHISM
 Polymorphism means "many forms.“ It allows one interface to
be used for different types (objects). It is mainly achieved through
method overriding and method overloading.

 Method Overriding: When a subclass provides a specific


implementation of a method that is already defined in its
superclass.

 Method Overloading: Methods in the same class have the same


name but different parameters.
10
ABSTRACTION
 Abstraction is the concept of hiding complex implementation details
and exposing only the essential features of an object.

 In OOP, abstraction allows programmers to focus on what an object does


rather than how it does it.

 Abstract classes and interfaces are used to achieve abstraction.

 Abstract classes provide a way to define the structure of an object


without implementing every detail, while interfaces allow different
classes to share common behavior without necessarily sharing an
inheritance relationship. 11
CONCLUSION
 This lecture covers the fundamental concepts of Object-Oriented Programming:
 Classes define blueprints for objects.
 Objects are instances of classes.
 Methods define behaviors of objects.
 Encapsulation restricts access to data and provides controlled access via
methods.
 Inheritance allows one class to inherit properties and methods from another
class.
 Polymorphism allows objects to be treated as instances of their parent class,
with behaviors specific to their actual type.
 Abstraction hides implementation details and exposes only essential features.
Can be achieved using abstract classes or interfaces.
12
Assignment

Sample Questions:
1. What is the purpose of encapsulation in OOP?

2. Explain the difference between method overriding and method


overloading.

3. How does inheritance promote code reusability in object-


oriented programming?

You might also like