• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Roundup Game Question #118

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question :
Can a method have more than one access modifier?
Answer :
No
How about public static or public native? The answer seems to assume only private, public, protected and default are access modifiers.
Please clarify.
Thanks,
Sanjay
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
static or native are not access modifiers.
K Dhingra
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sanjay,

Modifiers are Java keywords that gives the compiler information about the nature of code,
data, or classes. Modifiers are:
public
protected
private
final
abstract
static
native
transient
synchronized
volatile
From the above list of modifiers public, proteted and private are access modifiers. Remaining
modifiers do not fall in this category.

Note: default is a keyword in Java but it is not Access Modifier and "friendly" is not a
keyword in Java.
Normally when people talk in Java about class, data, methods which don't have any access modifier
they say that it has a defalut access modifier. The use of word default here is incoerrect. As default
is a keyword in Java. Instead friendly word is used.
"Friendly is not a Java keywords; it is simple a name that is given the access level that result from
not specifying an access modifier." OR in other words
"Friendly is the name of the default access of classes, variables, and methods, if you don't
specify an access modifier."
Regards,
Raj.

reply
    Bookmark Topic Watch Topic
  • New Topic