






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of polymorphism in java, focusing on early and late binding, upcasting, downcasting, and cloning. Early binding selects methods at compile time based on object type in code, while late binding chooses methods at runtime for more flexibility. Upcasting and downcasting are discussed, including when they are possible and the use of instanceof to check for downcasting. The document also covers the importance of implementing the clone() method correctly when copying objects.
Typology: Slides
1 / 11
This page cannot be seen from the preview
Don't miss anything!







Homework 4 due now Homework 5 posted due in 2 weeks
Early binding chooses methods at compile time (runs based on object type in code)
Late binding chooses methods at run time (can pick most appropriate method) What determines early/late binding?
When can you upcast (without error)?
You can implement clone() using a copy constructor (better way in Ch. 13) You should make sure that when copying, you use clone() instead of a class's copy constructor (See: Animal.java and Dog.java)