This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes is this true? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "is this true?" Watch "is this true?" New topic
Author

is this true?

geet kaur
Ranch Hand

Joined: Sep 03, 2008
Posts: 78
a public static method in a class can be called by its subclass wihtout explicitly refreing to the class???
if true then help me undersatnd this
thanks in advance!!!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19342
    
  41

Originally posted by geet kaur:
a public static method in a class can be called by its subclass wihtout explicitly refreing to the class???
if true then help me undersatnd this
thanks in advance!!!


Well, have you actually tried it? It just takes a few minutes to write a test program.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rekha Srinath
Ranch Hand

Joined: Sep 13, 2008
Posts: 178
Yes. Its because static methods cannot be overridden. And since the subclass actually HAS the superclass, ie.Superclass's methods are a part of the subclass, and since there is only one copy of the static method, you can call the static method in the subclass without the parent's object.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by geet kaur:
a public static method in a class can be called by its subclass wihtout explicitly refreing to the class???
if true then help me undersatnd this
thanks in advance!!!


hmmm...also public is not necessary...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: is this true?