Lecture7Inheritance

Lecture7Inheritance - Inheritance Inheritance Inheritance...

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

View Full Document Right Arrow Icon
Inheritance
Background image of page 1

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

View Full DocumentRight Arrow Icon
Inheritance Inheritance is a method for extending existing classes by adding methods and fields
Background image of page 2
superclass The more general class is called a superclass or base class The more specialized class that inherits from the superclass is called the subclass
Background image of page 3

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

View Full DocumentRight Arrow Icon
Object Every class extends the Object class either directly or indirectly
Background image of page 4
Object methods clone( ) equals(Object obj) finalize( ) getClass( ) hashCode( ) notify( ) notifyAll( ) toString( ) wait( ) wait(long timeout) wait( long timeout, int nanos)
Background image of page 5

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

View Full DocumentRight Arrow Icon
Inheritance vs. interface The subclass inherits behavior and state from the superclass What is behavior ? What is state ?
Background image of page 6
UML for inheritance Draw a closed arrow with a hollow tip that points to the superclass
Background image of page 7

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

View Full DocumentRight Arrow Icon
What is this good for???? Code reuse (e.g. JFrame)
Background image of page 8
All of the methods of the superclass are available for use New methods can be added (i.e. extend
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 25

Lecture7Inheritance - Inheritance Inheritance Inheritance...

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

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