272,187 views
36 votes
36 votes
Which of the following is a correct description of object-oriented programming (OOP)?

User Napon
by
3.1k points

1 Answer

14 votes
14 votes

Final answer:

Object-oriented programming (OOP) utilizes objects and classes, with principles such as encapsulation, inheritance, and polymorphism to create reusable and modular code.

Step-by-step explanation:

Object-oriented programming (OOP) is a programming paradigm that uses objects and classes. An object is an instance of a class, which is a blueprint for creating objects. A class defines the properties (often referred to as attributes or fields) and behaviors (also known as methods) that the objects created from the class will have. Encapsulation is a key principle of OOP that involves bundling the data with the code that manipulates it. It restricts direct access to some of an object’s components, which is why getters and setters are often used for accessing data in an object.

Inheritance allows a class to inherit properties and methods from another class, promoting code reusability. For instance, if you have a class named Animal, you might have another class named Dog that inherits from Animal and includes additional characteristics specific to dogs. Polymorphism is another concept in OOP that allows objects to be treated as instances of their parent class rather than their actual class. This lets a function operate on objects of different classes as long as they inherit from the same parent class.

User Opticon
by
3.3k points