What do you understand by variable

What do you understand by variable

Answer : Java variable is basically use as unit of storage in program. A variable is defined by the combination of type, identifier and an optional initializer. When we define the variables the they all have a scope, which defines their visibility, and a lifetime.

Variable declaration:
All variables should be declared before they can be used. The basic form of a variable declaration is shown below:

type identifier [ = value][, identifier [= value] ...] ;

long a, b, c; // declares three long variable a, b, and c
long d = 10, e, f = 20; // declares again and initializing
// d and f.
byte z = 22; // initializes z
double pi = 3.14159; // declares an approximation of pi.
char x = 'x'; // the variable x has the value 'x'.


Leave a Reply

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