6.3. Reference variable and object types
[7.2] Develop code that demonstrates the use of polymorphism; including overriding and object type versus reference type
For this exam objective, you need to understand that when you refer to an object, the type of the object reference variable and the type of the object being referred to may be different. But there are rules on how different these can be. This concept may take a while to sink in, so don’t worry if you don’t get it on your first attempt.
In the same way in which you can refer to a person using their first name, last name, or both names, objects of derived classes can be referred to using a reference variable of any of the following types:
- Its own type— An object of ...
Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.