constructor with return value is a legitimate member function
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Originally posted by Dan Culache:
Interesting! I didn't know that. Could you please give me an example.
Thanks.
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Originally posted by Dan Culache:
Thanks Dan, that I knew but I thought he really meant "constructors". This was my point, the way to differentiate between a constructor and a method with the same name is the fact the constructor doesn't have a return value. But I thought he might have come upon some weird scenario... If not then I'm not sure you cannot do the same in C++ since C++ has basically the same overloading rules.
BTW your mock exam is great. Perfectly suited for overconfident folks like I am![]()
for gc, understand how finally will affect program flow (e.g. if you return inside finally, the exception thown will be neglected and function will be returned normally, also exceptions thown inside finalizer are always ignored) and understand when will object be eligible to gc (e.g. string literals never get gc-ed)
...the way to differentiate between a constructor and a method with the same name is the fact the constructor doesn't have a return value.
..C++ has basically the same overloading rules.
Originally posted by Sri Sri:
Aaron, I am just confused, was it "finally" or "finalize" that you meant? i am sure it was a typo![]()
Sri
Originally posted by Aaron Anders:
"finally" is a keyword used for exception handling
"finalizer" means the gc-related method protected void finalize() throws Throwable
[ February 09, 2003: Message edited by: Aaron Anders ]
Originally posted by Sri Sri:
Aaron,
i know the difference between finally and finalize. I was asking what you meant when you said the exceptions thrown in finally will not be thrown ?
I guess it is finalize...because as far as i know ...
if there are exceptions thrown in finally, then you need to catch them using nested try-catch block inside the finally block or you have to declare the exception thrown in finally block in method declaration.
On the other hand, finalize method is called when the object is about to be GCed for the first time. If the object is resurrected from the finalize method, then finalize method is not called again...also... if there are exception thrown in finalize method, they dont really matter.
I thought you mixed up finally and finalize in your code......thats why I asked the question...
Thanks
Sri
[ February 09, 2003: Message edited by: Sri Sri ]
for gc, understand how finally will affect program flow (e.g. if you return inside finally, the exception thown will be neglected and function will be returned normally