KnowledgeBoat Logo

Computer Applications

Define the following with an example each:

(a) Implicit type conversion

(b) Explicit type conversion

Values & Data Types Java

ICSE

93 Likes

Answer

(a) Implicit type conversion

In implicit type conversion, the result of a mixed mode expression is obtained in the higher most data type of the variables without any intervention by the user. Example:

int a = 10;
float b = 25.5f, c;
c = a + b;

(b) Explicit type conversion

In explicit type conversion, the data gets converted to a type as specified by the programmer. For example:

int a = 10;
double b = 25.5;
float c = (float)(a + b);

Answered By

65 Likes


Related Questions