Question
Which of the following is an example of Polymorphism in
Object-Oriented Programming?Solution
Polymorphism allows one interface to represent multiple implementations . This can occur through method overriding , where a subclass provides a specific implementation for a method declared in its parent class, or method overloading , where methods have the same name but different parameters. For instance, an Animal class might have a sound() method overridden in subclasses like Dog or Cat to produce specific sounds. Polymorphism enables flexibility and extensibility, as the same method can be applied differently based on the object. Why Other Options Are Incorrect : 2. A class that inherits properties from another class : This is Inheritance , not Polymorphism. 3. A class that uses another class as a part of its definition : This describes Composition , where objects are combined to form complex systems. 4. A way to restrict access to certain class members : This is Encapsulation , not Polymorphism. 5. A way of dividing a complex system into smaller components : This is closer to the concept of Modularization , unrelated to Polymorphism.
If A: B = 2:3 and B: C = 3:4 find the value of (A+B): (B+C): (C+A).Â
- A sum of Rs. 9,450 is split among P, Q, and R in the ratio 3:2:1. What is the share of Q?
In a city of population 7200, the ratio of males to females is 11:7. If 400 females join the city, the ratio becomes 33:x. Find the value of (33 − x)....
A bag contains 10-paisa, 20-paisa and 50-paisa coins in the ratio of 8:6:7, respectively. If the total amount in the bag is Rs. 44, then find 25% of the...
The ratio of senior to junior employees in the company is 7:5. The ratio of male to female junior employees is 3:2, and the overall ratio of male to fem...
- If 72% of (P - Q) is equal to 30% of 60% of (P + Q), then find the value of Q:P.
Number of faculties in Physics and Biology in an institute is in the ratio of 5:7 respectively. If 45 more faculties join Physics, while 24 more faculti...
- Find the third proportion of 15.2 and 19.
Total population of city P and Q is 3410 and 4620 respectively. If the ratio of number of males to females in city is P and Q is 7:4 and 4:3 respectivel...
In a mixture of 40 liters, the ratio of milk to water is 5:3. How much milk must be replaced by water so that the new ratio becomes 1:1?