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 compound interest received on investing Rs. 10,000 for 2 years at 'y'% p.a., compounded annually is Rs. 3,689. The simple interest earned on investi...
A certain sum when invested for 3 years in a scheme offering simple interest of 16% p.a. gives an interest of Rs. 1128. What is 160% of the sum invested?
What will be the amount if a sum of Rs. 6500 is placed at compound interest for 3 years while the rate of interest for the first, second and third years...
A total amount of Rs.39,800 is split among three siblings named 'Ajay', 'Bijay', and 'Chetna'. 'Ajay' receives an amount that is in the ratio of 7:8 com...
Rohit made an investment that yielded a simple interest rate of r% per annum, allowing the principal to grow to 180% of its original amount in 5 years. ...
- Rohit invests Rs. 7,500 on compound interest at 10% p.a. (compounded annually) for 2 years and Rs. 6,400 on simple interest at 12% p.a. for 4 years. Find t...
Simple interest and compound interest (compounded annually) earned on a sum at the end of 2 years at a certain rate of interest p.a. are Rs. 2560 and Rs...
At what % of simple interest per annum will Rs. 320 amount to Rs. 480 in five years?
A certain amount earns simple interest of Rs. 1520 after 5 years. Had the interest been 6% more, how much more interest would it have earned?
Rs. 7000 is invested in scheme ‘A’ for 2 years and Rs. 5000 is invested in scheme ‘B’ for 2 years. Scheme ‘A’ offers simple interest of 15% ...