0% found this document useful (0 votes)
5 views4 pages

Programming Work

The document discusses the advantages of object-oriented programming (OOP) over procedural programming, highlighting benefits such as modularity, code reusability, reduced data redundancy, enhanced security, and improved productivity. It also explains why C++ is considered an OOP language, detailing features like classes and objects, encapsulation, inheritance, polymorphism, and abstraction with simple examples. Overall, it emphasizes the efficiency and effectiveness of OOP principles in software development.

Uploaded by

wiafeokyere
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Programming Work

The document discusses the advantages of object-oriented programming (OOP) over procedural programming, highlighting benefits such as modularity, code reusability, reduced data redundancy, enhanced security, and improved productivity. It also explains why C++ is considered an OOP language, detailing features like classes and objects, encapsulation, inheritance, polymorphism, and abstraction with simple examples. Overall, it emphasizes the efficiency and effectiveness of OOP principles in software development.

Uploaded by

wiafeokyere
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

NAME: KWADWO WIAFE AKENTENG OKYERE

INDEX NUMBER: 2425403957


QUESTION
1. State and explain any five advantages of using object-
oriented programming over procedural programming.
ANSWER:
 Modularity for easier troubleshooting: OOP groups
data and functions into self-contained objects. This
makes it easier to isolate and fix errors without
crashing the entire system.

 Code reusability through inheritance: You can create a


new class that inherits properties from an existing one.
This eliminates the need to rewrite common code,
saving time and reducing bugs.

 Data redundancy: Inheritance and polymorphism


allow developers to maintain a single repository of
code, which helps in reducing duplicate code
throughout the project.

 Security through encapsulation: By using access


specifiers, OOP hides sensitive data from outside
interference, ensuring that internal object logic is not
accidentally modified.

 Better productivity: OOPsystems can be easily


upgraded from small to large systems, and the
modular nature allows different team members to
work on different objects simultaneously.

QUESTION
2. Why is C++ considered an object-oriented
programming language? Explain your answer by
discussing any five object-oriented features supported by
C++ with simple examples.
ANSWER:
C++ is considered an OOP language because it supports
the creation and manipulation of objects-units that
combine data and methods that operates on them.

 Classes and objects


A Class is a blueprint, while an Object is an instance of
that blueprint.
EXAMPLE: A class Car defines properties like speed,
while an object myTesla is a specific car with a speed of
100mph.

 Encapsulation
This involves wrapping data and functions into a single
unit and restricting direct access to some component.
EXAMPLES: Using a private variable for a bank balance
so it can only be changed via a deposit() funtion.

 INHERITANCE
Inheritance allows a “child” class to acquire the
properties of a “parent” class.
EXAMPLE: A class Dog can inherit from a class
Animal, gaining the eat() function automatically.

 POLYMORPHISM
This allows one interface to be used for a general class of
actions. The most common form is “Function
Overloading”
EXAMPLE: A function draw() could behave differently
if you are drawing a Circle verses a Square.
 ABSTACTION
Abstraction means showing only the essential features of
an object and hiding the complex background details.
EXAMPLE: When you use a pow(x, y) function, you
know it calculates power,but you do not need to see the
complex mathematical algorithm running inside.

You might also like