class A{
some variables;
public void a()throws Excepion1,Exception2{....}
}
class B extends A{
variables...
public void a()throws E2,E3{.....}
}
Qns:
here override of methods occurs or not,ore else wil give
any compilation error or run properly..plz tell me briefly
whts happening with the above codes....

Answer Posted / anjan singh

while overriding, you must keep in mind that the exception
being thrown by overriding method(method in subclass)
should not throw a broader exception than what is already
thrown by method in super class. one exception is that, you
can always throw RuntimeException from method in subclass.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can long be null in java?

540


Name some OOPS Concepts in Java?

632


How many types of flags are there?

516


Assume a thread has lock on it, calling sleep() method on that thread will release the lock?

617


Can we use different return types for methods when overridden?

552






What occurs when an object is constructed?

560


What is a vararg?

537


What are the elements of java?

547


Can we call the constructor of a class more than once for an object?

619


What is the maximum size of arraylist in java?

484


Can we have two methods in a class with the same name?

576


What is boolean flag in java?

570


What do you mean by an object in java?

624


What are constants?

592


Is string serializable in java?

538