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?
About Question enthuware.ocajp.i.v7.2.1373 :
Moderator: admin
-
- Posts: 20
- Joined: Tue Aug 27, 2013 3:16 am
- Contact:
Online
HTH,
Paul.
-
- Site Admin
- Posts: 10067
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1373 :
That is correct.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.
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).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?
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 234 guests