Object Concepts and Terminology-2

Original methods can be overridden by including a new

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: •  Improves code reusability by extending , not ediDng, parent code. Updates to the parent will automaDcally pass through to the child classes aZer recompiling. IntroducDon to Inheritance Extending a Parent Class A subclass can extend its parent class by adding new fields, constructors, and methods. Original methods can be overridden by including a new version in the subclass. A few notes about overriding a parent class: •  The new method should have the same signature •  Constructor requirements are sDll maintained •  Both the original and overridden methods are always available •  To access the original method, use the keyword super....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online