Showing posts with label Types Of Variables. Show all posts
Showing posts with label Types Of Variables. Show all posts

Java-Types of Variables / Chapter - 5 /Language Fundamental



Java Types Of Variables


Based on the position of declaration & behavior all variables are divided into three parts.


1.instance variable


2.static variable


3.local variable




 


1.instance variable:-



  • If the value of a variable varied from object to object is called Instance variable.

  • For every object, a separate copy of instance variable will be created.

  • Instance variable should be declared within the class directly, but outside of any method/block/constructor.

Java-Types of Variables / Chapter - 5 /Language Fundamental


javabychetan.blogspot.com

Based on the position of declaration & behavior all variables are divided into three parts.


1.instance variable

2.static variable

                                   3.local variable


1.instance variable:-

  • If the value of a variable varied from object to object are called Instance variable.
  • For every object, a separate copy of instance variable will be created.
  • Instance variable should be declared within the class directly, but outside of any method/block/constructor.
  • Instance variable will be created at the time of object creation & destroyed at the time of object destruction. So the scope of the instance variable is exactly same as the scope of the object.
  • Instance variable will be stored in the HEAP memory as the part of an object.
  • We can't access the instance variable directly from STATIC area, but we can access it by using "object reference".
  •  We can   access the instance variable directly from instance area.  

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com