• Post Reply Bookmark Topic Watch Topic
  • New Topic

Modifiers in java  RSS feed

 
radha gogia
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just wanted to know that why are final and abstract called as modifiers ,what is the essence of calling them as modifiers since there are two types of modifiers access modifiers and non-access modifiers so final and abstract come under the second category ,so why are these called as modifiers?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37469
539
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand the question. A modifier is used to change the meaning of the declaration. As you noted, there are two types.

Saying "modifier" is just shorthand for "access or non-access modifier."
 
Zulfiquiar Khan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess because they modify the behaviour of any class member onto which they are appllied
 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
radha gogia wrote:two types of modifiers access modifiers and non-access modifiers


I haven't seen the categorization of modifiers on Java Language Specification(JLS)

But whenever they are talking about public, protected, default or private modifier - they use the term 'access modifier'
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Radha ,
final and abstract are two different things ...
For Final :

"final" has a few different meanings. Applied to a variable, it prevents changes to the variable after initialization, making it a "constant." Applied to a method, it does, indeed, prevent overriding. Applied to a class, it prevents the class from being extended. All of these meanings have something in common: they allow the programmer to have fairly strong beliefs about the value or purpose of something. If you know a class can never be extended, then you know for sure how an instance of the class will behave -- you know you're not dealing with a subclass that changes something, since you know no subclasses can exist. This helps with both engineering and security.


For Abstract :
An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.
An abstract method is a method that is declared without an implementation

Satya
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!