File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
The Java EE 7 Tutorial Volume 1 or Volume 2
this week in the
jQuery UI in Action
Programmer Certification (SCJP/OCPJP)
concept of method overriding
Joined: Mar 07, 2006
May 24, 2006 10:15:00
why we can't use narrowing method in sub class on the case of method overriding
Thanks in advance
Joined: Oct 02, 2003
May 24, 2006 11:15:00
i think it is because of
say you have a ClassA, with a public doSomething() method.
now, ClassB extends ClassA. say you could make B's doSomething() private.
now you make a collection of ClassA. you get a ClassB object, which you can put into the collection, since a ClassB is a ClassA.
now you iterate through the collection, calling doSomething() on every object. when you get to that ClassB, you're gonna have a problem...
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: concept of method overriding
Problem with mock exam question
Trying to access a servlet on button click
HELP: doPost without throw
Nikos Blog Overloading Question 58
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014