Why is it possible to delete an exception "release" statement from the signature of an inherited method?

Asked

Viewed 36 times

2

I would like to know because I did not understand this part, it is because it is a statement that it can "launch" an exception?

//EXEMPLO
public abstract class Personagem{
    public abstract void atacar() throws Exception;
}
//Atacar é abstrato
//logo abaixo quando eu herdo eu posso tirar o throws Exception da assinatura.
public class Mago extends Personagem{
    public void atacar(){
    }
}
  • I don’t understand your question. Be clearer please. Put the code you have doubt.

  • I hope I’ve made more concrete what I meant.

1 answer

1


The method atacar() is being overwritten in the subclass Mago, that is, the method is not invoked in the superclass Personagem and shall not make an exception.

Browser other questions tagged

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