What is the difference between typecasting and typeconversion in C++ or Java ?
If you concentrate on Java and numeric types, according Javadoc I think the main differences between type casting and type conversion are:
To consider more detail, first(without information and precision loss), conversion can be done without information and precision loss. These conversions include: byte to short, short to int, char to int, int to long, int to double and finally float to double. For example:
byte b = 2;
System.out.println(b);
short s = b; // without information and precision loss (type conversion)
System.out.println(s);
result:
2
2
Secondly(precision loss), conversion is performed with precision loss, it means that the result value has the right magnitude however with precision loss. These conversions include: int to float, long to float and long to double. For example:
long l = 1234567891;
System.out.println(l);
double d = l; // precision loss (type conversion)
System.out.println(d);
result:
1234567891
1.234567891E9
Thirdly (information loss), conversion is done via information loss, it means that you are casting the values, so it has its own syntax. These conversions include: double to long, double to int and so forth. For example:
double d = 1.2;
System.out.println(d);
long l = (long) d; // information loss
System.out.println(l);
result (fractional part is omitted):
1.2
1
Typecasting is just taking a pen and writing "this is now a int" on the variable, conversion is actually convert the content to the desired type so the value keeps having a sense.