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 city did American Express open its largest campus worldwide?
Match the following market structures with their correct descriptions:
1. Oligopoly
2. Monopoly
3. Monopolistic Competition
...
Which of the following private sector bank has launched two new products – loan against deposits and dollar bonds – for non-resident Indians at its ...
What is the minimum percentage of the total assets owned by the borrower that is required for an ARC to effect change in or takeover of the management ...
What is the time frame within which a Payment Service Provider (PSP) must commence operations after receiving the Certificate of Authorization from IFSCA?
How much did IIFCL invest in Infrastructure Investment Trusts (InvITs) during FY2023-24, as mentioned in the Annual Report of IIFCL 2023-24?
Once a company declares the dividend, amount of dividend should be deposited in scheduled bank within _____ and should be paid out within _____ from the...
What advantage do niche financial centers have over larger centers?
How many projects worth USD 40 billion has the New Development Bank approved so far?
Which of the following is true regarding Micro, Small and Medium Enterprises?
1. a micro enterprise, where the investment in plant and machinery...