5 Internal Functionalities of Compiler meanwhile of Assigning the value to variable directly

In way assigning the value to variable with the help of another variable. In this the syntax we technically called as 'casting'.

Casting: Converting from one variable data type value to another variable data type value.
for ex: byte b=100;
            int  a = b;

In this byte b = 100;   what internally is going to happen when compiler is evaluating this statement.

We have byte b = 100   Here b= destination variable and blue part is source place.

1) First Compiler check the destination variable type. In our case it is 'byte'.

2) Then Going to check the range of data type. In our case it is -128 to 0 to 127.
How to Calculate range of data types?   

3) Check the Source value. In our case it is 100.

4) Value to Check is within the range or not.
-128 to 0 to 100 to 127.

5) If not in a range compiler is going to give Compile time error.

Previous
Next Post »