aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes private & Static Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "private & Static" Watch "private & Static" New topic
Author

private & Static

Tony reedy
Greenhorn

Joined: Jan 11, 2002
Posts: 21
I want to know if I understood the concept correctly.I would appreciate answers for the following questions.
1)private memeber are not visible in subclass .so if we define any method same as super class method then it is a new method in sub class .so it is not overriding.
Are private methods inherited?
2)static methods are hidden in subclass.any sub class method same as super method will be a new method in sub class.so it is not overriding.
Are static methods inherited?
Brian Lugo
Ranch Hand

Joined: Nov 10, 2000
Posts: 165
Tony!
You may want to check this out ...
http://www.javaranch.com/maha/Discussions/Language_Fundamentals/difference_between_static_and_final_method_-_JavaRanch_Big_Moose_Saloon.htm
Brian
Tony reedy
Greenhorn

Joined: Jan 11, 2002
Posts: 21
Hi brian,
I did go thru many questions in this site.After all this ,I got the above concepts.Correct me if i am wrong.Did I mess up some things.
--also I would appreciate answers for the above questions.
Thanks
Tony
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Hello,
The best way to answer your questions would be to write some code and see what happens.
Good Luck,
-Dirk Schreckmann


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Tony reedy
Greenhorn

Joined: Jan 11, 2002
Posts: 21
i did do some sample programs.I know what will be the out put .what i want to know is ..what will be the answers if a question like
are private members inherited?
are static members inherited?
-thanx
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
1)private memeber are not visible in subclass. so if we define any method same as super class method then it is a new method in sub class. so it is not overriding.

true.

Are private methods inherited?

no.

2)static methods are hidden in subclass. any sub class method same as super method will be a new method in sub class. so it is not overriding.

true.

Are static methods inherited?

Yes, as long as they are not hidden by a new method of the same signature in the sub class and they are not private.
[ March 08, 2002: Message edited by: Marilyn deQueiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Uday Kumar
Greenhorn

Joined: Jan 22, 2002
Posts: 24
Finally Tony got the answers he was looking for.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
On the contrary...
Writing some code helps to give us a fuller picture of what's going on.
Marilyn, I'm not explicitly disagreeing with your explanation on inheriting static methods. I contend that static methods are not inherited in every polymorphic sense of inheritance.
Consider:



Good Luck,
-Dirk Schreckmann
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: private & Static