Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Why can the final modifier be used with static methods?

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello to all,
This question popped up in my mind as I was taking up one of the mock tests.Before the question, just a background of the relevant concepts
Abstract modifier: requires that the method HAS to be overridden
Final modifier: requires that the method CANNOT be overridden
Now with respect to the static methods. Static methods cannot be overridden (only hidden)
Thus abstract modifier cannot be applied to static methods because they cannot be overridden. I therefore expected the same argument to hold good for the final modifier. However it is not so and the final modifier can infact be applied to the static methods..This got me thinking...
Any comments abt this??
Sirish
 
stable boy
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It does make sense to have a method final static. You cannot hide (override) a final static method but you can hide a static method.
It makes sense for variables to declare them as final static, they are considered to be constant where static variables are not constant.
 
We can walk to school together. And we can both read this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic