Principle of Programming Language

Q. : Explain the different categories of scalar type variables with their advantage and disadvantages.

Variables are identifiers used in a program to represent the different kinds of data. The variables holding data of scalar data types are known as scalar variables. They are the most common ways of storing data.

The scalar variables are used to hold fundamental types of data in a program. Literals can also be used to refer to data in a program. Based on the kind of data stored or represented, the variables or the literals belong to the respective data type.
The scalar type variables are introduced in a program by means of declarations. A declaration is a

statement in a program that defines variables of a specific data type. A variable declaration statement fixes the name and data type of the variables it defines. The type then restricts the set of possible values which can be stored in the variables and also defines the memory requirements for storing actual values. In Java such amount of memory is fixed for each type and known at compile time. Variables declaration is essential for their use. If we do not declare variables they are not known to the compiler, it is not able to check if they are used according to the restrictions of the type, they belong to. Hence, all the variables must be declared prior to using them in a program. The format of declaring the scalar variables is given below:

type varl, var2, varN ;

where,
type represents a valid data type
varl, var2, varN represent variable names that are called declarators.