Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Coming soon... www.javatales.com
Coming soon... www.javatales.com
Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Originally posted by Jesper Young:
About the static method: The error message that the compiler gives you is indeed strange, because static methods cannot be overridden.
According to the Java Language Specification section 8.4.8, a static method can hide (but not override) other static methods in superclasses.
The fact that you get an error is correct; in section 8.4.8.3 the JLS says:
"A method declaration must not have a throws clause that conflicts (�8.4.6) with that of any method that it overrides or hides; otherwise, a compile-time error occurs."
It's just the wording of the error message from the compiler that's incorrect - it should have said "fun() in B cannot hide fun() in A" instead of "override".
The Java compiler isn't perfect, it's also just a piece of software written by a human being...
Sandeep Atluri
by over-riding we can have polymorphic calls like this
Parent parent = new Child();
parent.overriddenMethod();
by hiding we can just block Parent methods to have our own child implementation. ( No polymorphic calls.)
(see my example posted above)
Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Originally posted by Srinivasan thoyyeti:
Hi Vikrant,
Wanna add one more point: RuntimeExceptions are not checked. we can decalre a method throw Any RuntimeException irrespective of parent throwing it or not.
[ August 14, 2007: Message edited by: Srinivasan thoyyeti ]
Coming soon... www.javatales.com
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
I think she's lovely. It's this tiny ad that called her crazy:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|