Start learning 50% faster. Sign in now
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 is the application of GSAT-30 satellite?
In June 2020, the President of India promulgated the Banking Regulation (Amendment) Ordinance, 2020. Which of the following is the main feature of this...
In which part of India does the hot wind ‘Loo’ blow?
In which city is the headquarters of Nonghyup Bank (NH Bank), a specialized agricultural bank, located?
According to the Global Hunger Index 2022, which neighbouring country is only behind India with a rank of 109 out of 121 countries?
P, Q, R, S, T and U are six friends. Which of the following is/are sufficient to compare heights of S and T?
1. R is shorter than P but taller...
Who among the following advocated the ideology of "oru jati, oru matam, oru daivam manushyanu" (one caste, one religion, one god for humankind)?
Which day is observed on 11th July?
Identify the dam that is located in South India.
Which one of the following is not among the labour codes that consolidated multiple central labour laws?