Skip to content
Question 93 of 97

Q.Write four features of object oriented programming.

Punjab PsebCBSE Class XII Board 2019Subjective· 2mImportance★★★★★
96% · 93/97 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Object-Oriented Programming (OOP) is a paradigm that structures programs around objects rather than functions and logic, offering benefits like modularity and reusability through key features: Encapsulation, Inheritance, Polymorphism, and Abstraction.

Object-Oriented Programming (OOP) is a fundamental programming paradigm that models real-world entities as "objects." The core idea is to organize software design around data, or objects, rather than functions and logic. This approach aims to make software more modular, flexible, and easier to maintain and extend. The features discussed below are the pillars that enable these advantages.

Here are four key features of Object-Oriented Programming:

  1. Encapsulation

    Encapsulation is the bundling of data (attributes) and the methods (functions) that operate on that data into a single unit, known as a class. It also involves restricting direct access to some of an object's components, meaning that the internal state of an object is hidden from the outside world. This is often achieved using access modifiers like private or protected.

    The "why" behind encapsulation is data integrity and control. By preventing direct external access to an object's internal data, you ensure that the data can only be modified or accessed through predefined methods. This protects the data from unintended corruption and allows the class designer to enforce specific rules or validations when data is manipulated.

    Watch out

    A common misconception is that encapsulation is just data hiding. While data hiding is a crucial aspect, encapsulation also includes the bundling of data and methods together.

  2. Inheritance

    Inheritance is a mechanism that allows a new class (subclass or derived class) to inherit properties and behaviors (attributes and methods) from an existing class (superclass or base class). This establishes an "is-a" relationship between classes. For example, a Car "is a" Vehicle.

    The primary benefit of inheritance is code reusability. Instead of writing the same code multiple times for related classes, you can define common functionalities in a base class and have other classes inherit them. This reduces redundancy, makes code easier to maintain, and promotes a hierarchical classification of objects.

  3. Polymorphism

    Polymorphism means "many forms." In OOP, it refers to the ability of an object to take on many forms, or more specifically, the ability of a method to behave differently depending on the object it is called on. This often manifests in two main ways:

    • Method Overriding: A subclass provides a specific implementation for a method that is already defined in its superclass. When the method is called on an object of the subclass, the subclass's version is executed.
    • Method Overloading: Multiple methods within the same class have the same name but different parameters (number, type, or order of arguments). …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.