Non è che non si può fare; la classe "figlia" non può avere delle eccezioni superiori a quelle della classe madre; per esempio puoi fare:
Codice PHP:
class A {
public A() {
}
public void leggi() throws IOException{
}
}
class B extends A {
public B() {
}
public void leggi() throws FileNotFoundException, IOException{
}
}
Infatti FileNotFoundException è una sottoclasse di IOException; ma non puoi fare:
Codice PHP:
class A {
public A() {
}
public void leggi() throws FileNotFoundException{
}
}
class B extends A {
public B() {
}
public void leggi() throws FileNotFoundException, IOException{
}
}