Difference between Implicit Conversion and Explicit Conversion | Implicit Conversion vs. Explicit Conversion
|Implicit Conversion is done automatically.
|Explicit Conversion is done programatically.
|In Implicit conversion, no data loss take place during the data conversion.
|In explicit conversion, data loss may or may not be take place during data conversion. Hence there is a risk of information loss.
|No possibility of throwing exception during the conversion and therefore is called type safe.
|It might throw error if tried to do without type casting.
|Implicit conversion do not require any special syntax.
|Explicit conversion do require cast operator to perform conversion.
| Example :
Conversion of smaller number to larger number is implicit conversion.
Conversion of integer type data to float.float i=0;
// This is implicit conversion since float is larger than integer,hence no loss of data & no exception.
| Example :
Conversion of larger number to smaller number is explicit conversion.float k=123.456
int i= (int) k
// This is Explicit conversion and (int) is type cast operator. Here we may be able to escape an exception but there is noticeable data loss.i.e. i=123
// .456 is lost during conversion