your above code in main method
Alpha g = new Beta();
// now it's create a new actual object of Beta class with refrence of Alpha
g.Gamma();
// * now compiler look only Gamma() method presents in Alpha class off cource it present in Beta class also by default through inheritance.but compiler looked only at class Alpha and ask a question is contains a method Gamma() and found a answer yes it has.
suppose a condition when java compiler gives facility to throws more checked exceptions in gamma() method in Beta Class then what will happen
now at compile time compiler only depend on Gamma() method of class Alpha.it does not force to handle this exception or throws this exception which is wrong because it might throw(supposing to java compiler allow throwing more checked exception in overridden method).
but in reality compiler not make restriction on throwing exceptions but also on accessibility modifier.
because non static method invocation happen on actual object method not on type and we give to any super type and at compilation time compiler only check accessibility and presence in that type of assigned class.
so i think that's the reason behind this overridden contract
• The method definition cannot narrow the accessibility of the method, but it
can widen it.
• The method definition can only throw all or none, or a subset of the
checked exceptions (including their subclasses) that are specified in the throws
clause of the overridden method in the superclass.