KnowledgeBoat Logo
|

Computer Applications

Define the following with an example:

coercion

Values & Data Types Java

53 Likes

Answer

In a mixed mode expression, when the data type of the result gets converted into the higher most data type available in the expression without any intervention of the user, is known as Implicit Type conversion or Coercion.

Example:

int a = 42;
long b = 50000;
long c= a + b;

Here, a is int, b is long so the result of a + b automatically gets converted into long and assigned to variable c which is of long type.

Answered By

34 Likes


Related Questions