Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static method inheritance

 
Sri In
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java says a static method cannot be overridden because static method is Class level method.
Then why cant the above justification apply for inheritance.Why a static method is inherited.
Please justify.
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quite simply, because the language specification says so.

The Java Language Specification: Inheritance, Overriding and Hiding
 
Sri In
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah I know it is according to specification.
But I am not getting what is the reason behind that.
Can anybody help me
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

static methods can be overridden by static method in sub class if you override in nonstatic method compiler complines you the error overridden method is static..
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sri Sri"
Please check your private messages for an important administrative matter.
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry manesh i wont repeat it another time.....
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
santhosh.R gowda wrote:sorry manesh i wont repeat it another time.....


???
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
santhosh.R gowda wrote:
static methods can be overridden by static method in sub class if you override in nonstatic method compiler complines you the error overridden method is static..


Santosh,

Its not overridden , its called hiding. OverridingVsHiding
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic