• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

the" fina"l and "static'

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Which two declarations prevent the overriding of a method?(choose two.)
A. final void methoda () {}
B. void final methoda () {}
C. static void methoda () {}
D. static final void methoda () {}
E. final abstract void methoda () {}
Answer: A,C
would you tell me why ?
and would say something about final,static
 
Ranch Hand
Posts: 216
VI Editor Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by lang lang:
1. Which two declarations prevent the overriding of a method?(choose two.)
A. final void methoda () {}
B. void final methoda () {}
C. static void methoda () {}
D. static final void methoda () {}
E. final abstract void methoda () {}
Answer: A,C
would you tell me why ?
and would say something about final,static


Because that's exactly what final keyword is designed for. When use for method it means the method is not overriable.
static keyword using on a method meant that the method belong to the Class,
not to the Object's instance. And Java language says what belong to the Class stays with the class and only belong to the class and not inherited.
Since the idea of overriding is to override inherited stuff, and static method is not inherited..by default it is not overriable. You can have the same method on the child class, but it is called shadowing..not overriding.
Hope that helps.
 
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!