Textbook Notes (290,000)
CA (170,000)
Ryerson (10,000)
ITM (900)
ITM 200 (20)
Chapter 12

Chapter 12


Department
Information Technology Management
Course Code
ITM 200
Professor
Vikraman Baskaran
Chapter
12

This preview shows page 1. to view the full 4 pages of the document.
Chapter 12 – More on classes
12.1 Composition
Composition (aka aggregation) is the concept of a class having other classes as the types
of 1 or more of its attributes
The concept of composition implements the so-called has a relationship between classes
oIn other words, you should implement a link between 2 classes A and B using
composition
oIf you can say that A has a B, or vice versa
oFor example, a car has an engine, a cooker has an oven
12.2 Inheritance
A class A can inherit from a class ‘B’ by including the wordsextends B” in the
declaration of class A as follows
opublic class A extends B {
o}
This means that A will have all the attributes and methods of B
This is an important part of object-oriented programming
It allows classes developed for 1 application to be reused in another
Main purpose of the toString() method in class Object is to specify that all Java classes
are to have a toString() method
Example of car passengers to show the concept of inheritance on pg 247-249
Protected indicates that this attribute is visible within the classPerson” and within any
classes that inherit the classPerson” for examplePassenger” class
oIf we used private, then any object fromPerson” class would not be available in
thePassenger” class
Super invoke (call upon) thePerson” class constructor
oExample on pg 249
www.notesolution.com
You're Reading a Preview

Unlock to view full version