About Question enthuware.ocpjp.v7.2.1128 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
costin1989
Posts: 15
Joined: Tue Apr 21, 2015 1:36 am
Contact:

About Question enthuware.ocpjp.v7.2.1128 :

Post by costin1989 »

Overriding method cannot throw any exceptions that are not thrown by the overridden method.

and your answer is False.

so you mean the overriding method can throw any exceptions that are not thrown by the overridden method.

This code is valid?

class A{
void m1() throws IOException{}
}

class B extends A{
void m1() throws Exception {}
}

Thanks!

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1128 :

Post by admin »

No, if you want to get into the grammatical sense, the opposite of that statement would be, "Overriding method can throw some exceptions that are not thrown by the overridden method". The "some" would include subclasses of those exceptions and unchecked exceptions.

HTH,
Paul.

toolforger
Posts: 38
Joined: Fri Nov 13, 2015 4:40 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1128 :

Post by toolforger »

The "some" would include subclasses of those exceptions
Well, an exception of a subclass is also an exception of the superclass, so that's not really true.

Agreed on unchecked exceptions.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests