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: 10036
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: 10036
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: 10036
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.

Denyo1986
Posts: 38
Joined: Thu Jan 07, 2021 2:47 am
Contact:

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

Post by Denyo1986 »

Question:
Private methods cannot be overridden in subclasses.

Correct Answer:
not true / unchecked


>>>>> I think this is wrong. Cause when you read YOUR OWN explanation:
"Only methods that are inherited can be overridden and private methods are not inherited."

Only methods that are inherited can be overridden. Privat methods are not inherited. So private methods THEREFORE cannot be overridden in subclasses. It is the logical conclusion of your own explanation.
This question is highly ambiguous and should be changed in my opinion.

Very curious to hear your response to this.

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

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

Post by admin »

It is indeed marked as correct! See attached screenshot (option 1 and 5 are in green).
test.png
test.png (50.85 KiB) Viewed 4429 times
If you like our products and services, please help us by posting your review here.

Denyo1986
Posts: 38
Joined: Thu Jan 07, 2021 2:47 am
Contact:

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

Post by Denyo1986 »

Wow, such a quick reply. That is great. Thanks a lot.
And I am afraid you are right....I confused the highlighting.
My apologies.

Have a nice day

Tester
Posts: 34
Joined: Mon Oct 30, 2023 11:55 am
Contact:

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

Post by Tester »

The overriding method may opt not to declare any throws clause even if the original method has a throws clause.
Sorry, what does it mean "opt" here?

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

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

Post by admin »

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

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 47 guests