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.
Read the passage below and answer the question that follows:
Many cities are replacing conventional streetlights with smart LED lighting syst...
In the question given below, a passage/statement is followed by three statements which may or may not strengthen the assertion made in the passage.
Rohit: I renewed my car insurance through AutoSure.com. Their premium was much lower than what traditional agents quoted. The process was quick, and I ...
Which of the following combination is not true?
Statement: Should there be a complete ban on extracurricular activities in college.
Arguments:
I. No, there is nothing wrong in partic...
Statement: Should national anthem be played before movies in the theater.
Arguments:
I. Yes, this is the only way to show your love fo...
The World Health Organization (WHO) has announced a new initiative to reduce global smoking rates by 30% by 2030. This ambitious goal aims to decrease s...
In the question given below, a passage/statement is given followed by three statements which may or may not strengthen/weaken the assertion made in th...
Each question given below consists of a statement, followed by two arguments numbered I and II. You have to decide which of the arguments is a 'strong'...
How many person lives above one who likes Orange?