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 of the following state has topped NITI Ayog’s Export Preparedness Index 2021?
Who serves as the CEO of Reliance General Insurance Company, which has launched "Reliance Health Global," a healthcare policy aimed at making global hea...
From when is the RoDTEP scheme being restored for AA holders, EOUs, and SEZs?
At the 16th World Future Energy Summit, it was emphasized that global renewable energy capacity needs to reach at least ____ terawatts by 2030.
Tamil Nadu recorded temperatures exceeding which degree Celsius during the heatwaves in April and May 2024?
Which digital geo-spatial platform was launched by the Government of India to advance agricultural management?
India's largest floating solar power plant was inaugurated and fully operationalised in Tuticorin, Tamil Nadu. Which company inaugurated and fully opera...
Which countries are participating in the Desert Knight Exercise?
Microsoft has announced to set up its fourth data centre in India in ______________. It will be one of the largest data centres in India and will be ope...
What is the annual seedling production capacity target for the modern nurseries under the Clean Plant program?