News Ticker

Member’s Non-Access Modifiers

Below is a summary of the principle characteristic of the access and non-access modifiers.


final:


  • Prevents a method from being overridden.
  • A final argument cannot be overridden.


abstract:


  • Has no method body.Ends in semicolon and not {}
  • NEVER used with final, private, static
  • Only abstract classes or interfaces can contain abstract methods.
  • An abstract class can have non-abstract methods also it can have zero abstract methods.
  • All abstract methods must be implemented by subclasses unless the subclass is abstract.
  • Concrete class must implement all abstract methods.


synchronized:


  • Only applies to methods.
  • The method can be accessed by only one thread at a time.
  • Can be used with public, private, protected and package default


native:


  • Only applies to methods.
  • The method is implemented in platform-dependant code.
  • Has no code and ends with a semicolon.


strictfp:


  • Forces floating points to adhere to the IEEE754 standard.
  • Method can be strictfp even if class is not.


transient:


  • The JVM will skp this variable when serialising an object.
  • Applies only to instance variables.


Volatile:


  • Applies only to instance variables.

Leave a Reply

%d bloggers like this: