asked 169k views
0 votes
Method overload is very useful for maintaining system consistency even if the parameter type changes at different points. There are some special cases that even the type being different Java interprets the value as being of the same type. When we asked for the "Void LancordiaSatstate (int Dias)" method and pass the following information:

Integer numerodias = 5;

LancordiaSatstate (numerodia);

Java interprets that they are of the same type, even if in reality they are not (int primary type and intersect an object). Check the alternative that explains why Java interprets this way

Alternatives

Alternative 1:

Java understands that they are numbers.


Alternative 2:

Java checks by approaching types.


Alternative 3:

Java holds an implicit conversion of the type type to integer


Alternative 4:

Java internally calculates a type and always converts to the primitive.


Alternative 5:

Java can only perform this operation using a casting.

1 Answer

2 votes

In this operation, the java will interpret the int primary type and integer as the same type by It is a implicit conversion performed before the analysis of the expression itself, where the int intra type will be converted. ( alternative 3 ). Two types of conversions are performed whenever a logical expression or arithmetic presents different variables and types.

The two types of conversions are:

  • implicit conversion - automatically performed by compiler .
  • Explicit conversion - performed by programmer .

< /p>

no implicit conversion , the compiler will perform the conversion of all different types and variables in one type, to Only then do the Evaluation of the expression itself. Strong> will perform this operation forcibly, to prevent errors from occurring during process execution, thus reaching the desired result.

answered
User Biophetik
by
8.1k points

No related questions found