Question:

Which of the following is a correct statement regarding object-oriented programming (OOP)?

Show Hint

To understand OOP:
- Focus on objects combining data and methods.
- Learn key principles: Encapsulation, Inheritance, Polymorphism, Abstraction.
- Compare with procedural programming, which uses sequences of instructions.
  • OOP is based on functions rather than data
  • In OOP, objects can have both data and methods
  • In OOP, the program is written as a sequence of instructions
  • OOP does not support inheritance
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

To determine the correct statement about object-oriented programming (OOP), we need to understand its core principles.
Step 1: Understand OOP
OOP is a programming paradigm that uses objects, which are instances of classes.
It emphasizes data (attributes) and the methods (functions) that operate on that data, encapsulated together.
Key principles include encapsulation, inheritance, polymorphism, and abstraction.
Step 2: Analyze Option A - OOP is based on functions rather than data
OOP is centered around objects that combine data and methods, not just functions.
This is more characteristic of procedural programming, not OOP.
Thus, option A is incorrect.
Step 3: Analyze Option B - In OOP, objects can have both data and methods
In OOP, objects are instances of classes that contain both data (e.g., variables or attributes) and methods (e.g., functions or behaviors).
This reflects the principle of encapsulation, a core feature of OOP.
Thus, option B is correct.
Step 4: Analyze Option C - In OOP, the program is written as a sequence of instructions
Writing a program as a sequence of instructions is typical of procedural programming, not OOP.
OOP focuses on objects and their interactions rather than a linear sequence.
Thus, option C is incorrect.
Step 5: Analyze Option D - OOP does not support inheritance
Inheritance is a fundamental OOP principle, allowing a class to inherit properties and methods from another class.
OOP does support inheritance, making this statement false.
Thus, option D is incorrect.
Step 6: Conclusion
The correct statement aligns with OOP’s definition, where objects encapsulate both data and methods.
Was this answer helpful?
1
0