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 perpendicular and base of a right-angle triangle is, 14 cm and 48 cm, respectively, then find the length of the shortest median of triangle.
Calculate the hypotenuse of an isosceles right-angled triangle where the equal sides are 8√6 cm each.
- The sides of two similar triangles are in the ratio 5:7. The areas of these triangles are in the ratio:
Area of a triangles with vertices at (2, 3), (-1, 0) and (2, -4) is :
What is the area of triangle ABC with vertices A(1, 2), B(5, 6), and C(7, 2)?
- The sides of a triangle are in the ratio 7:24:25. If the area of the triangle is 336 cm², what is the perimeter of the triangle?
In the given figure, AB ∥ QP, AB = x, PQ = x + 10, RB = x/2, BP = x + 1. Find PQ.
A triangle has sides 13, 14, 15. Find its area.
If the inradius of a triangle with a perimeter of 60cm is 8 cm, then find the area of the triangle.(in cm2)
- Find the area of a triangle with a base of 12.6 cm and a corresponding height of 18.4 cm.