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.
A sum of money, invested for 8 years on 5% per annum simple interest, amounted to ₹287 on maturity.
What was the sun invested in?
A&B invested their sum in the ratio of 22: 25. Respectively. In two different schemes. Offering simple interest of 15% per annum and compound interest o...
A sum of money gets six times in 8 years , in how many years it will be 216 times in CI?
A sum of money amounts to Rs. 5,320 in 4 years at simple interest at 8% per annum. What is the principal?
Find the simple interest and amount on Rs 9,000 at 7% per annum for 3 years.
Rs. 90Y when invested for 5 years at simple interest of 12% p.a., yields an interest of Rs. 2700. If Rs. 110Y is invested for 3 years at compound intere...
Mr. P invested Rs. ‘8x’ in scheme ‘A’ offering simple interest of 25% p.a. and reinvested the interest earned from scheme ‘A’ at the end of ...
The simple interest received on a certain sum is Rs. 400 less than the sum invested. If the sum was invested at 15% p.a. for 5 years, then find the simp...
Rs. 180000 is invested at x% simple interest for 5 years and it becomes Rs. 207000. What will Rs. 120000 amount to if it is compounded for 2 years at (x...
A sum of money amounts to Rs. 5600 in 5 years at 8% simple interest per annum. Find the principal and the interest earned.