Question
Which of the following best represents the concept of
polymorphism in Object-Oriented Programming?Solution
Polymorphism in Object-Oriented Programming (OOP) allows methods to be defined in different forms across different derived classes, typically by overriding or overloading methods. This enables a single method to exhibit multiple behaviors, depending on the object that invokes it. For example, a base class method draw() in a shape class could be defined differently in derived classes like Circle and Rectangle, where each class implements its unique version of draw(). This approach promotes flexibility, reduces code duplication, and allows developers to manage code easily as new classes are added, embodying one of OOP’s core principles. Polymorphism is critical for creating extensible and maintainable code, as it enables a system to process objects of various types through a common interface. Option A (Encapsulation) - Encapsulation is the OOP principle of hiding internal details and exposing only necessary features through a class interface, which differs from polymorphism’s focus on varied behaviors. Option C (Aggregation) - Aggregation describes a "has-a" relationship between classes, where one class contains references to another, unrelated to polymorphic behavior. Option D (Encapsulation) - This concept of grouping related fields and methods within a class refers to encapsulation, not polymorphism. Option E (Unrelated Classes) - Allowing objects of unrelated classes to connect without a common functionality does not represent polymorphism, which requires shared interfaces or inheritance.
Which institute’s incubator NSRCEL and Goldman Sachs’ online business education programme for women 10,000 Women has launched Goldman Sachs 10,000...
Which company recently launched a voice-based digital payment option for booking LPG cylinders?
The Ministry of Corporate Affairs have increased the threshold for paid up capital to not exceeding ______.
According to the UNFPA's 'India Ageing Report 2023,' what percentage of the country's total population is projected to be constituted by the elderly pop...
Who among the following is the writer of the novel ‘The room on the roof’ ?
Which regulatory body awarded Karnataka Vikas Grameena Bank (KVGB) for significant enrolment under the Atal Pension Yojana (APY)?
Despite pledging to reduce fossil fuel subsidies, the G20 countries increased the amount of public money flowing into coal, oil, and gas in 2022. What w...
- Which military aircraft was part of India-U.S. defence discussions for potential purchase?
According to a UN report, what is causing the world’s water cycle to become increasingly unpredictable?
- In which Indian city was the AI centre for Geospatial Analytics established by the Maharashtra government in partnership with Microsoft?