• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Modifiers for Methods

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Folks,
Can somebody please confirm if this summarized list correct. The list is incomplete too with lots of question marks. Please help me complete the list. Thanks in advance.

Access Modifiers for methods
1. Public method
2. Private method
3. Protected method
4. Default method

Non-access Modifiers for methods
1. Final method
2. Abstract method
3. Static method
4. Synchronized method
5. Native method
6. Strictfp method

Combination of ACCESS + NONACCESS modifiers for methods1. final + abstract --> not allowed
2. final + static -----> allowed
3. final + synchronized --> ?
4. final + native --> ?
5. final + strictfp -->
6. abstract + static --> ?
7. abstract + synchronized --> ?
8. abstract + native --> ?
9. abstract + strictfp --> ?
10. static + synchronized --> ?
11. static + native --> ?
12. static + strictfp --> ?
13. synchronized + native --> ?
14. synchronized + strictfp --> ?
15. native + strictfp --> ?
16. final + with {coderanch, private, default, protected} --> allowed
17. abstract + with {only public } --> allowed
18. static + with {coderanch, private, default, protected} --> allowed?
19. synchronized + with {coderanch, private, default, protected } --> allowed
20. native + with { coderanch, private, default, protected} --> allowed?
21. strictfp + with {coderanch, private, default, protected} --> allowed?
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The easiest way to find the answer would be to try it yourself. Generally what you need to remember is that final and abstract cannot be used together and private and abstract cannot be used together. Generally modifiers like synchronized, strictfp are not constrained and can be used with other combination...
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way i used to remember is you can not have any non access modifier along with abstract in a metod.

Also you can not have private and abstract and native and strictfp together

All other combinations are allowed.

Correct me if i am wrong.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic