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.
The procurement of goods and services by central public sector enterprises (CPSEs) through Government e-Marketplace (GeM) grew 74 per cent to _______dur...
Which U.S. state will implement the country's first climate impact fee through Act 96 starting in January 2026?
For what purpose did Abu Dhabi Future Energy Company PJSC – Masdar prepare to host the World Future Energy Summit in 2024?
Which of the following statements is true regarding the PM-PRANAM scheme approved by the Cabinet Committee on Economic Affairs?
What is the prize amount for the best all woman team in the HaRBInger 2024 hackathon?
Technotex 2023 to be held in _____?
Who was the Chairman of Hinduja Group and recently passed away in London?
Where did Uber launch its first water transport service in Asia?
With whom has the Indian Council of Agricultural Research signed an MoU to empower farmers?
Which of the following horses won the Indian Turf Invitation Cup under S. Padmanabhan’s training?