About Question enthuware.ocajp.i.v7.2.1373 :

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

Moderator: admin

Post Reply
Zoryanat
Posts: 20
Joined: Tue Aug 27, 2013 3:16 am
Contact:

About Question enthuware.ocajp.i.v7.2.1373 :

Post by Zoryanat »

Hi there.

I was under impression that we look at reference class to see what methods we have access to but if the method in question is overridden in subclass, and actual object that reference referring to is of that subclass, then the overridden version of that method will be called.
Here though you say "2. Whether a call needs to be wrapped in a try/catch or whether the enclosing method requires a throws clause depends on the class of the reference and not the class of the actual object." - is that something that applies only in cases when throwing exceptions is involved?

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

Re: About Question enthuware.ocajp.i.v7.2.1373 :

Post by admin »

Hi there.

I was under impression that we look at reference class to see what methods we have access to but if the method in question is overridden in subclass, and actual object that reference referring to is of that subclass, then the overridden version of that method will be called.
That is correct.
Here though you say "2. Whether a call needs to be wrapped in a try/catch or whether the enclosing method requires a throws clause depends on the class of the reference and not the class of the actual object." - is that something that applies only in cases when throwing exceptions is involved?
I am not sure I understand your question but this goes back to your point 1 above. You are looking at the declaration of the method in the class of the reference (not of actual object) to determine whether you have to put the call in try/catch or not (Or declare the throws clause of the caller appropriately).

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

Post Reply

Who is online

Users browsing this forum: No registered users and 234 guests