09-Inheritance&Composition

09-Inheritance&Composition - Chapter IX Inheritance...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Chapter IX Inheritance and Composition Chapter IX Topics 9.1 Introduction 9.2 Is-A and Has-A Relationships 9.3 Inheritance Program Examples 9.4 Composition Program Examples 9.5 The JackO'lantern Case Study 9.6 The Train Case Study 9.7 Using Super Class Identifiers 9.8 Summary Chapter IX Inheritance and Composition 449 9.1 Introduction Chapter IV introduced Object Oriented Programming. We took small steps and started by learning how to use class methods and object methods. In some later chapters you declared your own classes and created class methods and object methods. All these chapters taught you important OOP concepts, which can be combined under the title of encapsulation . Encapsulation is the OOP feature whereby the data of an object and all the methods, which access the data are placed in the same container. Understanding encapsulation is very important in learning OOP, but it is a first step. There are many steps to follow and learning inheritance is another important step along the OOP journey. You have already seen and used inheritance in many previous program examples. In chapter IV you were introduced to using graphics in Java and creating applets for web pages. In each one of your applet programs the class heading was followed with the words extends Applet . Little was mentioned about those words, but those two little words indicate that the current class will be using features that have already been declared in the Applet class. A programming language is initially so complex that it is often necessary to use various language features that are not immediately explained. Explaining everything may be very thorough, but such an approach will be very intimidating and certainly overwhelming. Now you are ready to explore inheritance. 9.2 Is-A and Has-A Relationships Object Oriented Programming is very popular for a good reason. There are so many features that make a program better designed, more reliable, easier to test and simpler to update than previous, non-OOP programs used to be. You have already seen a fair amount of encapsulation and learned the benefits of placing methods and data in the same module, along with constructors. Now let us see what inheritance can do for us. Do not be alarmed if you do not instantly see the great benefits of all this OOP stuff. OOP is very powerful, but it takes time to reach a comfort level with this programming approach. Imagine that you are very creative in designing custom vans. You know just how to replace regular seats with comfortable captain seats, add attractive paneling, 450 Exposure Java 2009, APCS Edition 08-08-09 provide lots of lights, install an entertainment system, and include many other goodies to make a simple van become a terrific vehicle for long road trips. Now are you interested in putting together the basic chassis, the frame, the doors, the engine, the transmission, the drive shaft, the air-conditioning and all the other details that a van requires? No, you do not care. Engines, transmissions and air-No, you do not care....
View Full Document

This note was uploaded on 10/14/2010 for the course APSC AP taught by Professor Kurt during the Spring '98 term at Wooster.

Page1 / 52

09-Inheritance&Composition - Chapter IX Inheritance...

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

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