wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Private Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Private Methods" Watch "Private Methods" New topic

Private Methods

Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
I think, that private methods can be overloaded in the same class, but can they be overloaded in the derived class? Consider this code:

Can the abc method in B overload the abc() in A , which is not private?

SCJP 1.4 85%
Jorg Klein
Ranch Hand

Joined: Feb 13, 2006
Posts: 33
private methods don't get inherited.

Try to call the private method of class A in class B.
You can't call it.
[ February 15, 2006: Message edited by: Jorg Klein ]
John Dell'Oso
Ranch Hand

Joined: Apr 08, 2004
Posts: 130

For future reference, when you have queries of this nature (and it is good to be inquisitive about things), you should type the code in, create the classes and try it out - learning by trying these little exercises yourself is an excellent way to learn (and probably come up with more questions).

Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
im not positive, because im a beginner myself, but it would make more
sense to me to use protected, instead of private, since you want to
share the info. with child classes.


You down with OOP? Yeah you know me!
Aum Tao
Ranch Hand

Joined: Feb 14, 2006
Posts: 210
Thanks John for your pragmatic advice. I understand that the best way to learn programming, or anything for that matter, is to practice it.
I agree. Here's the link: http://aspose.com/file-tools
subject: Private Methods
Similar Threads
Q from javacross simulation
Use of static modifier
How to get 100% in scjp 5.0 ?
Overloading static methods
Inheritance Query