Study resource

Read at your pace, then save it for later.

Unit 1: Principles of Object-Oriented Programming: Examination Resource

Section A — 1 Mark Questions

1. What does OOP stand for? [1 Mark]

Answer: OOP stands for Object-Oriented Programming.

2. Define an object in OOP. [1 Mark]

Answer: An object is a basic unit of object-oriented programming that represents a real-world entity and contains both data and methods.

3. What is the primary focus of procedural programming? [1 Mark]

Answer: Procedural programming focuses on a sequence of instructions or steps to solve a problem.

4. Identify the term for wrapping data and methods into a single unit. [1 Mark]

Answer: Encapsulation.

5. Name one object-oriented programming language. [1 Mark]

Answer: Java (or C++, Python, C#).

6. What is a class in OOP? [1 Mark]

Answer: A class is a blueprint or template from which objects are created.

7. Define abstraction in OOP. [1 Mark]

Answer: Abstraction is the process of hiding internal implementation details and showing only the essential features of an object.

8. What is inheritance? [1 Mark]

Answer: Inheritance is the mechanism where one class acquires the properties and behaviors of another class.

9. Define polymorphism. [1 Mark]

Answer: Polymorphism is the ability of an object or method to take on many forms.

10. In which programming paradigm is data given less importance than functions? [1 Mark]

Answer: Procedural Programming.

11. What is a method in OOP? [1 Mark]

Answer: A method is a function defined inside a class that describes the behavior of an object.

12. What does data hiding refer to? [1 Mark]

Answer: Data hiding refers to protecting the internal state of an object from unauthorized access using access modifiers.

13. Which concept allows a class to be derived from a parent class? [1 Mark]

Answer: Inheritance.

14. State the primary difference in data handling between procedural and OOP. [1 Mark]

Answer: Procedural programming treats data as global/separate, while OOP ties data closely to functions within objects.

15. What is dynamic binding? [1 Mark]

Answer: Dynamic binding refers to the association of a method call to its definition at runtime.

16. Name the principle that allows an object to hide its complexity. [1 Mark]

Answer: Abstraction.

17. What is a benefit of code reusability? [1 Mark]

18. Name one major benefit of OOP. [1 Mark]

Answer: Modularity and easier maintenance of code.

19. Can an object exist without a class? [1 Mark]

Answer: No, objects are instances created based on the definition provided by a class.

20. What is message passing? [1 Mark]

Answer: It is the process by which objects communicate with each other by invoking methods.

Section B — 2/3 Mark Questions

1. Differentiate between procedural and object-oriented programming based on data visibility. [2 Marks]

Answer: In procedural programming, data is often global and can be accessed by any function. In object-oriented programming, data is encapsulated within objects, and its visibility is controlled via access modifiers.

2. List three key benefits of OOP. [3 Marks]

Answer: 1. Code reusability through inheritance. 2. Improved modularity and easier maintenance. 3. Enhanced data security through encapsulation.

3. What is the significance of a class? [2 Marks]

Answer: A class acts as a template for creating objects. It defines the common data and behaviors that all objects of that type will possess.

4. Explain the concept of inheritance briefly. [3 Marks]

Answer: Inheritance allows a class (subclass) to inherit attributes and methods from an existing class (superclass). This promotes code reuse and creates a hierarchical relationship between classes.

5. How does encapsulation provide data security? [2 Marks]

Answer: Encapsulation bundles data and methods together and restricts direct access to the data from outside the object, preventing unintended modifications.

6. Define polymorphism with an example. [3 Marks]

Answer: Polymorphism is the ability to present the same interface for different data types. For example, a 'draw()' method could be used differently for a Circle and a Square object.

7. Why is procedural programming considered 'top-down'? [2 Marks]

Answer: It is called 'top-down' because the approach involves breaking down a large problem into smaller, sequential steps or functions, starting from the main program logic.

8. What is meant by modularity in OOP? [3 Marks]

Answer: Modularity refers to the practice of partitioning a program into distinct, independent sections (objects/classes). Each module contains specific data and logic, making the system easier to test, debug, and maintain.

9. Explain the difference between an object and a class. [2 Marks]

Answer: A class is the theoretical blueprint, while an object is the actual implementation (instance) of that blueprint in memory.

10. Briefly describe message passing. [2 Marks]

Answer: Message passing is the mechanism through which objects communicate by requesting services from other objects by invoking their methods.

Section C — 5 Mark Questions

1. Compare procedural programming and object-oriented programming in detail. [5 Marks]

Answer:

FeatureProcedural ProgrammingObject-Oriented Programming
ApproachTop-down approachBottom-up approach
FocusFocuses on functionsFocuses on objects/data
Data SecurityData is global, less secureData is hidden, more secure
ComplexityDifficult to manage large codeEasier to manage complex systems
ReusabilityLimited reusabilityHigh reusability via inheritance

2. Describe the core concepts of Object-Oriented Programming. [5 Marks]

Answer:

Core Concepts

  • Encapsulation: The practice of binding data and functions into a single unit (class), protecting it from outside interference.
  • Abstraction: Hiding complex implementation details and exposing only the necessary interface to the user.
  • Inheritance: The process where one class inherits properties from another, supporting code reuse and hierarchical design.
  • Polymorphism: The ability of a single function or object to behave differently in different contexts (e.g., method overloading/overriding).
  • Classes and Objects: The fundamental building blocks; the class defines the structure, and the object represents the individual instance.

3. Explain the benefits of using Object-Oriented Programming over other paradigms. [5 Marks]

Answer:

Benefits

  • Modularity: Code is organized into small, manageable units called objects, which makes development cleaner.
  • Maintainability: Since the code is compartmentalized, updating or fixing bugs in one module (object) does not necessarily break the entire system.
  • Reusability: Through inheritance, existing code can be reused in new classes without writing it from scratch, saving time.
  • Scalability: OOP makes it easier to expand complex software systems as new features can be added by creating new objects.
  • Security: Encapsulation ensures that data cannot be accessed directly, which reduces the chance of accidental corruption.

4. Elaborate on the role of Inheritance and Polymorphism in real-world application design. [5 Marks]

Answer:

Inheritance

Inheritance enables a 'is-a' relationship. For instance, in a payroll system, 'Manager' and 'Developer' classes can inherit common attributes like 'EmployeeID' and 'Salary' from a base 'Employee' class. This eliminates redundancy.

Polymorphism

Polymorphism allows a generic interface to perform varied tasks. For example, a 'processPayment()' method can be implemented differently for 'CreditCardPayment' and 'UPIPayment' classes. The main program does not need to know the specific type of payment; it just calls the common method. Together, these concepts allow developers to build flexible and extensible systems.

5. Discuss the transition from procedural programming to object-oriented programming. Why is OOP preferred for complex systems? [5 Marks]

Answer:

Transition

Procedural programming served the needs of early computing where tasks were simple sequences of events. As software grew, the global data used in procedural code became difficult to track and secure, leading to the rise of OOP.

Why OOP is Preferred

OOP is preferred for complex systems because it mimics real-world scenarios. In complex software, keeping track of global data is error-prone. OOP uses encapsulation to localize data changes. Furthermore, the ability to build upon existing code (inheritance) allows large teams to collaborate effectively. It transforms the programming task from writing 'what steps to take' into 'designing entities and their interactions,' which aligns better with how humans conceptualize complex problems.


xxx

Did this help you understand better?

Your feedback improves the quality of this resource for everyone.