Chapter 9 - Things to Watch for • ‘extends’ is a keyword • When overriding methods you have to use the exact same signature line • You

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

View Full Document Right Arrow Icon
    Chapter 9 Simple Class Extension
Background image of page 1

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

View Full DocumentRight Arrow Icon
    Some Benefits of OOD Nice program organization Being able to easily reuse previously  written code in the form of classes Being able to define multiple objects, each  with its own set of variables using one  class definition
Background image of page 2
    Class Extension is a another benefit of OOD gives you the ability to add on to or modify  an existing class without changing the  code of the original makes code re-use easier and less  headache-prone
Background image of page 3

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

View Full DocumentRight Arrow Icon
    Class Extension When you extend a class, you: own everything the extended class owned become an instance of the extended class
Background image of page 4
    Syntax class ChunkyMonkey extends IceCream { public final boolean yummy; ChunkyMonkey() { yummy = true; } } (Notice that every ChunkyMonkey object is also an IceCream object)
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

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

View Full DocumentRight Arrow Icon
Background image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Things to Watch for • ‘extends’ is a keyword! • When overriding methods, you have to use the exact same signature line • You can’t extend a class if it was declared ‘final’ Terms • If class B extends class A, then B is a subclass of A • Similarly, A would be the superclass of B – A single class can have multiple subclasses, but only one superclass More Terms • A method in a subclass that has the same signature as a method in its superclass is said to override the superclass’s method • A method in the superclass that is not overridden by the subclass is said to be inherited...
View Full Document

This note was uploaded on 01/28/2011 for the course CS 1131 taught by Professor Staff during the Fall '08 term at Michigan Technological University.

Page1 / 8

Chapter 9 - Things to Watch for • ‘extends’ is a keyword • When overriding methods you have to use the exact same signature line • You

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

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