This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes static problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static problem" Watch "static problem" New topic

static problem

geet kaur
Ranch Hand

Joined: Sep 03, 2008
Posts: 79
why can't we declare abstract methods as static...?i know that we can't ...but don't know the exact reason for it...please help!
Henry Wong

Joined: Sep 28, 2004
Posts: 20537

Static methods can't be overriden, so it really doesn't make sense to declare a static method as abstract, as there is no way to define it by subclassing.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Well, in short, because in Java, abstract method implementations are looked up at runtime by checking the exact type of the object the method is called on. Since static methods are called without reference to an object -- i.e., you can call them as ClassName.methodName(), with no object involved -- there would be no way to figure out which implementation you mean. Of course you could work out a system for doing this, but Java's creators wanted the language to stay simple, with relatively few rules for understanding its behavior.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: static problem
jQuery in Action, 3rd edition