lec13 - 1.00 Lecture 13 Inheritance Reading for next time:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1.00 Lecture 13 Inheritance Reading for next time: Big Java: sections 11.5-11.6 Inheritance Inheritance allows you to write new classes based on existing (super) classes Inherit super class methods and data Add new methods and data This allows substantial reuse of Java code invokes old code (libraries, etc.) We sometimes need to have old code invoke new code (even code that wasn’t imagined when the old code was E.g. A drawing program must manage a new shape Inheritance allows us to do this! When extending software, we often write new code that written), without changing (or even having) the old code!
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Class may contain members (methods or data) of type: Private: Access only by class’s methods Access by: Class’s methods Methods of inherited classes, called subclasses Package: Access by methods of classes in same package Public: Access to all classes everywhere A Programming Project Department has system with Student class Has extensive data (name, ID, courses, year, …) for all students that you need to use/display Dept wants to manage research projects better Undergrads and grads have very different roles Positions, credit/grading, pay, … Suppose Student was written 5 years ago by someone else without any knowledge that it might be used to manage research projects Protected (rarely used in Java; it’s pretty unsafe)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

lec13 - 1.00 Lecture 13 Inheritance Reading for next time:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online