Computer Scientists are Pretty Pessimistic

Wednesday 22 June 2016

What is Automatic Type Conversion and Automatic Type Promotion ?

Automatic Type Conversion:

Automatic conversion between compatible type is called type conversion. When one type of data is assigned to another type of variable an automatic type conversion will take place if the following two conditions are met,

1. The two types are compatible.

2. The destination type is larger than the source type.


Automatic Type Promotion:

While evaluating expressions Java automatically promotes all byte, short and char values to int and in case of the presence of a float or double they are promoted to float or double respectively. This is called automatic type promotion. 

No comments:

Post a Comment