Page 47 - CA_Blue( J )_Class10
P. 47
Dynamic Initialization
Initializing a variable during the execution of a program is termed dynamic initialization. Some examples are:
Data types Declaration Dynamic Initialization
int int a1, a2, a3; a1=a2 + a3;
float float i1, i2, i3; i1=i2 + i3;
String String c= "India", d= "Delhi", e; e= c + d;
3.7.2 Default Value
If you do not initialize a variable, the Java compiler provides a default value to a variable. We have already mentioned
the default value of each type of data types in the Data Types section.
Difference between Identifier and Variable
Identifier Variable
It is only used to identify an entity uniquely in a program at A variable is a name given to a memory location that is used
the time of execution. to hold a value.
3.8 TYPE CONVERSION
Type conversion is the process of changing one type value to another type. In Java, we can cast one type of value to
another type. It is also known as typecasting. It is required in situations when a method or an expression returns one
type of value and it is stored in a variable of a different data type.
There are two types of conversions in Java which are:
• Implicit Conversion
• Explicit Conversion
3.8.1 Implicit Type Conversion
Implicit type conversion takes place when the two types are compatible or the target type is larger than the source
type. For example, when we assign the value of a smaller data type to a larger data type, the implicit type conversion
is automatically done by the Java compiler. In implicit type conversion, the resultant data types are not specified and
are chosen by the compiler. The most important thing is that no part of the data value is lost.
Let us take an example:
You will get the following output:
45
Values and Data Types 45

