• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

private & Static

 
Tony reedy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 165
 
Tony reedy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
The best way to answer your questions would be to write some code and see what happens.
Good Luck,
-Dirk Schreckmann
 
Tony reedy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9061
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Uday Kumar
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally Tony got the answers he was looking for.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic