Pergunta de entrevista da empresa Apple

Write a simple class that inherits from a parent class and override one of the methods. If the method is called which code will be executed, the parent or the child class?

Resposta da entrevista

Sigiloso

18 de fev. de 2019

Depends on the object type. Parent obj = new Parent() would call parent method while Parent obj new Child() would call the child method. Assuming that these methods are not being called from the constructor. If they are then child method would call the parent and the child methods.