When declaring an interface in the class, who should implement it?

Asked

Viewed 75 times

3

class Gerente extends Funcionario implements Autenticavel {

He meant that Gerente implements the interface Autenticavel, or Funcionario which will implement the interface?

1 answer

8


The Gerente implement right below. The signature of this class has the interface, so it is this class that will have to implement.

If Funcionario has already been implemented, even if a reimplementation in Gerente, would not need to declare in this class, it would already be implicitly stated that it has inherited from a class that already has the interface.

I didn’t get into the merit that this particular heritage seems conceptually wrong because it’s not the focus of the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.