Given the two methods:

Void f() throws IOException

Which of the following is/are correct overriding method?

a) void f() throws IOException

b) public void f()

c) void f() throws FileNotFoundException

d) void f() throws Exception

Questions by lalithakasiraj

Showing Answers 1 - 3 of 3 Answers

imAjit

  • Dec 24th, 2012
 

a) void f() throws ioexception
Bcoz the overriding method must NOT throw checked exceptions that are new or broader than those declared by the overridden method. For example, a method that declares a FileNotFoundException cannot be overridden by a method that declares a SQLException, Exception, or any other non-runtime exception unless its a subclass of FileNotFoundException.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions