Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract methods

 
Puja S
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can abstract methods be static ?

Thanks
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An abstract method must be overridden and a static method cannot be overridden, so no.
 
Kris Reid
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not quite right.
You can override a static method.

However you can not have a abstract static method.
This is because a static method can belongs to the class and must have implementation so when called with out instanciating an object of the class it will work. A abstract method however has no implementation so can't be static.
 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

That's not quite right.
You can override a static method.


You cannot override static methods, what seems to be overriding is actually hiding. Please refer this link
for details.

and here is one more excellent article by Corey
click me
[ January 06, 2005: Message edited by: Jay Pawar ]
 
Krishna Srinivasan
Ranch Hand
Posts: 1862
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We cannot override static methods.
We can only hide the static methods.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic