Chapter 12

4 Pages
Unlock Document

Information Technology Management
ITM 200
Vikraman Baskaran

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 o In other words, you should implement a link between 2 classes A and B using composition o If you can say that A has a B, or vice versa o For 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 words extends B in the declaration of class A as follows o public 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 class Person and within any classes that inherit the class Person for example Passenger class o If we used private, then any object from Person class would not be available in the Passenger class Super invoke (call upon) the Person class constructor o Example on pg 249
More Less

Related notes for ITM 200

Log In


Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.