Figure 8.1 Inheritance: Relationships among timepieces.

Slides:



Advertisements
Similar presentations
Abteilung für Telekooperation Softwareentwicklung 2 UE SE2UE_ Vererbung (Inheritance)
Advertisements

Has-a Relationships A pen “has a” or “contains a” ball.
Inheritance. Many objects have a hierarchical relationship –Examples: zoo, car/vehicle, card game, airline reservation system Inheritance allows software.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Java Inheritance. What is inherited A subclass inherits variables and methods from its superclass and all of its ancestors. The subclass can use these.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
© 2006 Pearson Addison-Wesley. All rights reserved9 A-1 Chapter 9 Advanced Java Topics (inheritance review + Java generics)
Inheritance and object compatibility Object type compatibility An instance of a subclass can be used instead of an instance of the superclass, but not.
Two 2x2 (block) matrices can be multiplied C==AB
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
© 2006 Pearson Addison-Wesley. All rights reserved9 A-1 Chapter 9 Advanced Java Topics.
CS 106 Introduction to Computer Science I 11 / 28 / 2007 Instructor: Michael Eckmann.
CSCI 143 OOP – Inheritance 1. What is Inheritance? A form of software reuse Create a new class from an existing class – Absorb existing class data and.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
© 2006 Pearson Addison-Wesley. All rights reserved9 A-1 Chapter 9 Advanced Java Topics CS102 Sections 51 and 52 Marc Smith and Jim Ten Eyck Spring 2007.
Computer Science I Inheritance Professor Evan Korth New York University.
Chapter 7 - Generalization/Specialization and Inheritance1 Chapter 7 Generalization/Specialization and Inheritance.
Chapter 10: Inheritance 1. Inheritance  Inheritance allows a software developer to derive a new class from an existing one  The existing class is called.
Advanced Inheritance Concepts. In this chapter, we will cover: Creating and using abstract classes Using dynamic method binding Creating arrays of subclass.
Object Oriented Programming: Inheritance Chapter 9.
Inheritance using Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 8: Class Relationships Data Abstraction & Problem Solving.
Inheritance Chapter 10 Programs built from objects/instances of classes An O.O. approach – build on earlier work. Use classes in library and ones you have.
Inheritance and Access Control CS 162 (Summer 2009)
Inheritance Inheritance allows a programmer to derive a new class from an existing one The existing class is called the super class, or parent class,
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Advanced C++ Topics Chapter 8. CS 308 2Chapter 8 -- Advanced C++ Topics This chapter describes techniques that make collections of reusable software components.
Class Relationships And Reuse Interlude 4 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
Object Oriented Programming: Inheritance Chapter 9.
CS 106 Introduction to Computer Science I 04 / 18 / 2008 Instructor: Michael Eckmann.
Coming up: Inheritance
Creating Classes from Other Classes Appendix D © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2007 Lawrenceville Press Slide 1 Chapter 9 Inheritance  One class is an extension of another.  Allows a class to define a specialized type of an existing.
Inheritance and Polymorphism. Superclass and Subclass Inheritance defines a relationship between objects that share characteristics. It is a mechanism.
November 27, 2001Lecture 231  Previous Lecture: Parameter passing Method overloading  Today’s Lecture: Introduction to inheritance Class diagrams and.
Types of Inheritance in C++. In C++ we have 5 different types of inheritance: – Single Inheritance – Multiple Inheritance – Hierarchical Inheritance –
Inheritance Chapter 11 in Gaddis. Is a relationships in ‘real’ life Exist when one object is a specialized version of another one –Examples An english.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
1 Inheritance One of the goals of object oriented programming is code reuse. Inheritance is one mechanism for accomplishing code reuse. It allows us to.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Class Inheritance Part I
Sections Inheritance and Abstract Classes
OOP: Encapsulation &Abstraction
Advanced Java Topics Chapter 9
Classes and Inheritance
Python First Edition STARTING OUT WITH Chapter 10 Inheritance
Inheritance and Polymorphism
One class is an extension of another.
An Introduction to Inheritance
Road Map Inheritance Class hierarchy Overriding methods Constructors
Advanced C++ Topics Chapter 8.
CSC 205 Java Programming II
One class is an extension of another.
OBJECT ORIENTED PROGRAMMING II LECTURE 8 GEORGE KOUTSOGIANNAKIS
Inheritance, Polymorphism, and Interfaces. Oh My
Advanced Java Topics Chapter 9
Polymorphism Polymorphism - Greek for “many forms”
Java Programming, Second Edition
Chapter 9 Carrano Chapter 10 Small Java
Chapter 8: Class Relationships
Advanced Inheritance Concepts
Figure 8.1 Inheritance: Relationships among timepieces.
Presentation transcript:

Figure 8.1 Inheritance: Relationships among timepieces

Figure 8.2 The subclass Ball inherits members of the superclass Sphere and overrides and adds methods

Figure 8.3 An object invokes the correct version of a method

Figure 8.4 Access to public, protected, package access, and private members of a class by a client and a subclass

Figure 8.5 A ball “is a” sphere

Figure 8.6 A pen “has a” or “contains a” ball

Figure 8.7a area is overridden: a) mySphere.DisplayStatistics( ) calls area in Sphere

Figure 8.7b b) myBall.displayStatistics( ) calls area in Ball

Figure 8.8 VCR is a subclass of ACR

Figure 8.9 ACR has an abstract class (tape transport) and a derived class (VCR)