Coercion Coercion represents implicit parameter type conversion to the type expected by a method or an operator, thereby avoiding type errors. Fortunately, the compiler implicitly converts the second operand to double and uses the operator defined for two double operands. The third expression adds a double and a String . Once again, the Java language does not define such an operator. So the compiler coerces the double operand to a String , and the plus operator performs string concatenation.
Coercion also occurs at method invocation.
For the method invocation in the code below, the compiler implicitly converts the derived reference variable, which has type Derived , to the Base type prescribed by the method signature. Of course, the compiler still verifies that all type conversions conform to the defined type hierarchy. Overloading Overloading permits the use of the same operator or method name to denote multiple, distinct program meanings. Other forms exist for adding two integers, two longs, and so forth. We call the operator overloaded and rely on the compiler to select the appropriate functionality based on program context.