Tuesday, 4 February 2014

which are The access Modifier In java?

Access modifier are properties of a class/method/veriable while access modifier are five types


  • Final
  • static
  • Synchronization
  • Abstract
  • Transient

    Final :


    • A java variable can be declared using the keyword final. Then the final variable can be assigned only once.
    • A variable that is declared as final and not initialized is called a blank final variable. A blank final variable forces the constructors to initialise it.
    • Java classes declared as final cannot be extended. Restricting inheritance!
    • Methods declared as final cannot be overridden. In methods private is equal to final, but in variables it is not.
    • Final parameters – values of the parameters cannot be changed after initialization. Do a small java exercise to find out the implications of final parameters in method overriding.
    • Java local classes can only reference local variables and parameters that are declared as final.
    • A visible advantage of declaring a java variable as static final is, the compiled java class results in faster performance.

    0 comments:

    Post a Comment