|
Besides primitives, another kind of data type is an object reference. The type conversions occur in case of object references as well. Like primitives, the conversion takes place in contexts such as assignment of object references or while passing object reference as an argument in a method call. The basic concept behind the reference conversion is similar to that of the primitive conversion – “Java automatically performs type conversion when you convert a narrower data type to a wider object reference”. However determining which object reference represents a wider data type is the tricky part. This fact makes type conversion in object references bit difficult to understand. Before we dive into the rules of type conversion in references, let us first understand the three kinds of object references.