Explain your own answer with proper example?
Type Casting -- It is a method/process which is used to change one data type into another data type. It is also known as Type conversion. It is of two types -
1. Implicit - The conversion of data type automatically by the compiler is called Implicit
type casting.
ex - int x = 10 ,
char y = 'a' ,
x = x + y ( here y is implicitly converted into int type)
2.Explicit - The conversion of data type by the user or forced conversion of data type is called Explicit type casting.
ex - double x = 1.4 ,
int sum = (int)x + 2 ( here x is explicitly converted from double to int )