Question d’entretien chez Rakuten

Q1. What is polymorphism, overriding? Demonstrate by code example?

Réponse à la question d'entretien

Utilisateur anonyme

12 nov. 2024

Ans 1: Polymorphism is the ability of an object to take on many forms. Overriding is when a subclass provides a specific implementation of a method that is already provided by its parent class. Polymorphism allows objects to be treated as if they are of any of their compatible types. Overriding is used to provide a specific implementation of a method that is already provided by its parent class. Example: Animal class has a method called makeSound(). Dog and Cat classes extend Animal and override makeSound() method with their own implementation.