<span style= "FONT-SIZE:18PX;" ></span>
/*
This example is an exception in the inheritance of the problem, when bexception inherit Aexception, the parent class throws Aexception, then the child class can only throw aexception or bexception, and not throw other exceptions, because the subclass can not be more than the parent class " There is a problem. " Here is an example:
*/
<span style= "FONT-SIZE:18PX;" >class Aexception extends Exception{}class bexception extends Aexception{}class fu{public void Show () throws Aexceptio N{}}class Zi extends fu{public void Show () throws bexception//or throw bexception{}}class exceptiondemo3{public static void M Ain (string[] args) {Try{fu f = new Fu (); F.show ();} catch (aexception E)//can only be thrown aexception{}try{zi z = new Zi (); Z.show ();} catch (aexception E)//When a method in a subclass throws Bexception this also throws bexception{}try{fu F = new Zi (); F.show ();} catch (aexception E)//can only throw aexception, because polymorphic {}}}</span>
Java Learning notes--inheritance issues in exceptions