Thursday 8 May 2014

Difference between instance variable,Referance Variable,Local variable in JAVA




Instance Variable - The variable which we can use with in class and also referring those values in outside class is called instance variable.

Reference variable - The variable which used to create object is called refernce variable.

local Variable - local Variable lifetime will end with in the braces.

Example :

class b{
pubic calc(int b,int c){
int d=b+c
System.out.println(d);
}

class main{
public static void main(String args[]){
b obj1=new b();
obj1.calc(4,5);
}

from above example

b and c = instance variable
c = local variable
obj1=reference variable


No comments:

Post a Comment