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.
What will be the average of odd numbers between 20 to 74?
The average of the first six numbers is four times the average of the next three numbers. If the average of all nine numbers is 24, then find the sum of...
A group of 35 people has an average age of 28 years. Later, 7 more people join the group and the average age becomes 25 years. What is the average age o...
Neha spends an average of Rs. 480 on Sundays and Rs. 360 on the remaining days. Find her average spending in a 30-day month starting with Sunday.
Average of 20 numbers is 90. Average of first 8 numbers is 125 while average of last nine numbers is 40. If ninth number is 25% less than the tenth numb...
Average 20 numbers is ‘x’. If the average of first 12 numbers is 62.5 while average of last 5 numbers is 84.8 and 13th, 14th...
The ratio of number of girls to number of boys is 3: 2 in a class of 70 students. The average marks scored by the boys in Physics is 72 and the average...
Average run scored by a batsman in first ‘x’ matches is 88. In next 10 matches he scored runs with an average of 100 so that his over...
The average age of a class of 24 girls is 15 years. If 6 new girls having average age of 10 years join the class, then the average age of the class beco...
The university has 750 faculty (male and female only) out of which the females are 60%. The average height of females is 162 cm and that of males is 168...