Pergunta de entrevista da empresa Barclays

What is polymorphism and give me an example

Resposta da entrevista

Sigiloso

3 de nov. de 2024

Polymorphism is the concept of having many forms of the same class or interface in a program all related to each other through inheritance. An example would be if there was a class for Animal in a program, which had certain variables, methods, and constructors for it. If there was another class created called Dog, which is a type of animal, Dog class can be a child class of Animal, and it would inherit all of Animals properties while also being able to overload and override these properties so that it has its own properties specific to dogs.