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 measure has SBI implemented to provide faster SME Digital Business Loans?
An advanced Artificial Intelligence (AI) system for early detection of forest fires has recently been launched by which Tiger Reserve?
What was the minimum public float requirement for listing on international stock exchanges at Gift City before the Finance Ministry reduced it recently?
What is the name of the state health insurance scheme in Rajasthan that the government seeks to integrate with Ayushman Bharat?
The PM’s Internship Scheme provides financial assistance to interns. What amount is contributed by partner companies as part of the stipend?
The ISA’s World Solar Report series projected global solar capacity to reach how many GW by 2030?
Who is set to become the next prime minister of Pakistan after the recent elections?
_________ article of the indian constitution provides for civil code for the citizens.Â
India became the first country to surpass the $100 billion mark in remittances in 2022. Which of the following factors has likely contributed the most t...
The 3rd High-Level Conference on New Technologies for Clean Energy Transition, hosted by the ISA, released a report showing solar PV efficiency of what ...