About Question enthuware.ocajp.i.v8.2.945 :

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

Moderator: admin

Post Reply
sulakshana
Posts: 14
Joined: Thu Dec 22, 2016 8:55 pm
Contact:

About Question enthuware.ocajp.i.v8.2.945 :

Post by sulakshana »

The return type can also be a subclass of the original method's return type.....
checked and unchecked exceptions...
I did not got this 2 statements ... pls explain with details...thanx......

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

Re: About Question enthuware.ocajp.i.v8.2.945 :

Post by admin »

1. If the return type of a method in the base class is A, then the return type of the overriding method in a subclass can be A or any subclass of A. This is explained nicely here: http://www.javatpoint.com/covariant-return-type

2. Not sure what are you asking about checked and unchecked exception.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Arold Aroldson
Posts: 21
Joined: Mon Nov 20, 2017 8:00 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.945 :

Post by Arold Aroldson »

Why this option is incorrect? "An overriding method can declare that it throws a wider spectrum of checked exceptions than the method it is overriding."?
Overriding method can declare that it throws any amount of exceptions, isn't it?

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

Re: About Question enthuware.ocajp.i.v8.2.945 :

Post by admin »

No, the overriding method can only throw the same or narrower set of checked exceptions than the superclass's method.

Which book are you following?
If you like our products and services, please help us by posting your review here.

Arold Aroldson
Posts: 21
Joined: Mon Nov 20, 2017 8:00 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.945 :

Post by Arold Aroldson »

sorry, i didn't know that unchecked exceptions were not considered

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

Re: About Question enthuware.ocajp.i.v8.2.945 :

Post by admin »

Unchecked exceptions have no rules. That is why they are called "unchecked". They are not checked for any rules :)
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: gustavl and 4 guests