Instance Variable Cheatsheet

:: Instance Variable

  • Public, Private, Protected all 3 access modifiers can be applied to Instance Variable(Default also).
  • Instance variable will get default value means instance variable can be used without initializing it. Same is not true for Local Variable.
  • Instance Variable can be marked final.
  • Instance Variable can be marked transient.
  • Instance Variable can not be abstract.
  • Instance Variable can not have synchroonized modifier.
  • Instance Variable can not have strictfp modifier.
  • Instance Variable can not have native modifier.
  • Instance Variable can not have Static modifier as it will becomes Class level variable.
Instance Variable Type Default Value
boolean false
byte (byte)0
short (short) 0
int 0
long 0L
char u0000
float 0.0f
double 0.0d
Object null

Leave A Comment

Your email address will not be published. Required fields are marked *