Describe explicit conversion briefly.



Explicit type conversion is a type conversion which is explicitly defined within a program (instead of being done by a compiler for implicit type conversion).
double da = 3.3;
double db = 3.3;
double dc = 3.4;
int result = (int)da + (int)db + (int)dc; //result == 9
//if implicit conversion would be used (as if result = da + db + dc), result would be equal to 10

There are several kinds of explicit conversion.
Checked:
Before the conversion is performed, a runtime check is done to see if the destination type can hold the source value. If not, an error condition is raised.
Unchecked:
No check is performed. If the destination type cannot hold the source value, the result is undefined.

Next Post Previous Post
No Comment
Add Comment
comment url