This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why is this wrong? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Why is this wrong?" Watch "Why is this wrong?" New topic
Author

Why is this wrong?

Tony Sam
Ranch Hand

Joined: Nov 19, 2001
Posts: 32
"Static methods can be overridden by static methods only. " is Wrong, why is "Static methods cannt be overridden by non-static methods" correct ?
i dont understand it, hope someone helps!!

Tony Sam<BR>One want to be a SCJP...
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
Originally posted by Tony Sam:

why is "Static methods cannt be overridden by non-static methods" correct ?
Because compiler won't allow you.
"Static methods can be overridden by static methods only. " is Wrong.
Because static methods are hidden not overridden.
HTH
CMIW

------------------
Regards
Ravish


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
amit mawkin
Ranch Hand

Joined: Oct 31, 2001
Posts: 73
I agree with ravish static methods are hidden and are not overridden in subclasses
------------------
coffee drinker
-----------------------
Sun Certified Programmer for Java 2 Platform


regards, Amit
coffee drinker and Sun Certified Programmer for Java 2 Platform
Jim Hall
Ranch Hand

Joined: Nov 29, 2001
Posts: 162
This question was just posted yesterday.
http://www.javaranch.com/ubb/Forum24/HTML/013653.html
Tony Sam
Ranch Hand

Joined: Nov 19, 2001
Posts: 32
Originally posted by ravish kumar:
[b]why is "Static methods cannt be overridden by non-static methods" correct ?
Because compiler won't allow you.
"Static methods can be overridden by static methods only. " is Wrong.
Because static methods are hidden not overridden.
HTH
CMIW
[/B]

i know ,just one word : "Static method are not overridden." ,
is this OK?
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
yes it is, but they are hidden instead
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Andre Zhang
Greenhorn

Joined: Aug 14, 2001
Posts: 9
Originally posted by Valentin Crettaz:
yes it is, but they are hidden instead

does HIDDEN mean that the static method cant be accessed by the subclass?
Karen Leoh
Ranch Hand

Joined: Dec 03, 2001
Posts: 40
The following statements are true.. but I hope someone can elaborate on them..
Static methods are never overridden. They are hidden or shadowed just like fields.
Static methods cannot be shadowed by a non-static method and vice versa.
Static method can be shadowed by a static method in the subclass.
Can anyone one please elaborate what does hidden or shadowed means? What's the difference between the two?

--------------------<p>Karen Leoh<br />Sun Certified Programmer for Java™ 2 Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is this wrong?
 
Similar Threads
Overriding static methods
Overriding static methods
Static Methods
Static methods are inherited but not overriden
Redefining a static method in subclass