jQuery in Action, 2nd edition*
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 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static problem" Watch "static problem" New topic
Author

static problem

geet kaur
Ranch Hand

Joined: Sep 03, 2008
Posts: 78
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
author
Sheriff

Joined: Sep 28, 2004
Posts: 18138
    
  39

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.

Henry


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

Joined: Jul 08, 2003
Posts: 24168
    
  30

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: http://aspose.com/file-tools
 
subject: static problem
 
Similar Threads
Can you use static sections? (NOT static variables, this is diff)
static in inner class
question from master exam
using static method in polymorphism
Abstract Methods and Classes