Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can static method be inherited? be overrided?

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

the output is :aaa
so,the static method can be inherited.


the output is :zzz
so,the static method can be overrided.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fudong Jia,

This is not override. This is called the redefinition of abc() function.

Regards,
Manjunath.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are absolutely right. Its a redefinition of superclass method. And yes static methods are inherited.

Regards
Dipesh
 
Fu Dong Jia
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!
Can anyone tell me the different between redefinition and override in such a conditions.
thanks in advance!
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
----------------------------------------
code:


class Scott {
public static void abc() {
System.out.println("aaa");
}

}
public class Group extends Scott {
public static void main(String[] args){
Group.abc();
}


}



the output is :aaa
so,the static method can be inherited.
----------------------------------------------------

I was wondering why the above code giving output aaa?
As per my knowledge static means specific to class , not to any object.
how static method abc() is inherited into Group class?

I read the inheritance definition as follows.

"The ability of one class of objects to inherit properties from a higher class."

is the above definition wrong?
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy "Dee-Jay" and "Manjunath"!

Please have a look into your private messages by clicking the "My Private Messages" link near the top of this page.

Yours,
Bu.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

Please, could you send me your answer as private message too ?

Many thanks
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, for most discussion we prefer to use the public boards. There are some specific things that we find it's better to discuss privately, but basic java questions are not among them. In general we wnat to share knowledge, not hide it.

Additionally, Eric, I can't tell what part of this discussion you are asking about.

I recommend you check out Overriding vs Hiding for more info on the difference between overriding and "redefinition" (which is also called hiding).
 
Fu Dong Jia
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am agree with Jim !
 
Fu Dong Jia
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jim.
the link:Overriding vs Hiding got my doubt so clearly!
 
reply
    Bookmark Topic Watch Topic
  • New Topic