InterviewSolution
| 1. |
Variables in Java |
|
Answer» In Java, a variable is a data container that stores data values during the execution of a Java program. A data type is allocated to each variable, indicating the type and quantity of data it may store. It is a program’s fundamental storage unit. All variables in Java must be defined before they may be used. Syntax of declaring a variable:- datatype variable_name;Here, datatype refers to the type of data that can be stored in the variable. variable_name refers to the name of the variable being declared. In the above image, we can see that a variable named ‘age’ has been declared of type ‘int’ and has been initialised with the value ‘20’. Types of variables:-
|
|