⭐Variables


Home SQL Manual Testing Java Selenium

Defination:-
->Variables are used to store data.
or
->Variables are named memory location which can store some value/data and it changes 'n' number of times during excution.


⭐We can perform below operations on variables


1.Variable Declaration:- 2.Variable Initialization:-
Syntax:-
datatype variable_name;
exa:- int a;
Syntax:-
variable_name = value;
exa:- a=10;
3.Variable Utilization:- 4.Variable Declaration
and Initialization:-
exa:- System.out.println(a); Syntax:-
datatype variable_name = value;
exa:- int a = 10;

Types of Variables/DataTypes:-

1)Primitive DataTypes. 2)Non-Primitive DataTypes.
1)byte.
2)short.
3)int.
4)long.
5)float.
6)double.
7)char.
8)boolean.
1)Array.
2)String.
or
Any Class Type.

⭐The Difference Between Primitive and Non-Primitive Datatypes is Size.


⭐Variables are classified into

1)Local Variables 2)Global Variables
*Defination:-Any variable which is declared within the method is called as local variable.

*The scope of local variable is from the begining of method still end of the method.

*It will not have default value.

*It cannot be classified into Static or Non-Static.

*Local variable should be Initialized before Utilization.
*Defination:-Any variable which is declared outside the method and inside the class is called as local variable.

*The scope of Global variable is from the begining of class still end of the class.

*It will have default value.

*It can be classified into Static or Non-Static.

*Once the global vaiable is declared immeduately in next line it cannot initialize or reinitialize it will throw Compile Time Error(CTE)

⭐Default Values,Range,Size:-

Primitive Datatype Default Values Size(in bit's) Range
byte 0 8   -128 to 127  
short 0 16   -32,768 to 32,767  
int 0 32   -231 to 2 31-1  
long 0 64   -263 to 2 63-1  
float 0.0f 32 1.4e-045 to 3.4e+038
double 0.0d 64 4.9e-324 to to 1.8e+308
char  \000000 OR Unicode  16 0 to 65,535
boolean false 1 true or false
String null    

⭐Final Variable

Any Variable declares with a keyword final is called final variable.
Note:- Final Variable's cannot be re-initialized.