10 Reusing implementations through Inheritance

 

Exam objectives covered in this chapter

What you need to know

[9.1] Create and use subclasses and superclasses

Why and how to extend classes.

Where and how to use parent and child classes.

[9.2] Create and extend abstract classes

How to define abstract classes – with or without abstract methods.

How to extend abstract classes, creating concrete or abstract classes.

[9.3] Enable polymorphism by overriding methods

When to override implementations of base classes.

How to define polymorphic or overridden methods.

[9.4] Utilize polymorphism to cast and call methods, differentiating object type versus reference type

How to determine the valid types of the variables that can be used to refer to an object.

How to determine the differences in the members of an object, which ones are accessible, and when an object is referred to using a variable of an inherited base class or an implemented interface.

[9.5] Distinguish overloading, overriding, and hiding

The rules to spot method overloading, overriding and hiding.

10.1   Inheritance with classes

10.1.1   The need to inherit classes

10.1.2   Benefits

10.1.3   A derived class contains within it an object of its base class

10.1.4   Which base class members are inherited by a derived class?

10.1.5   Which base class members aren’t inherited by a derived class?

10.1.6   Derived classes can define additional properties and behaviors

10.2   Abstract classes

10.2.1   Defining an abstract class

10.2.2   abstract methods

10.2.3   Extending an abstract class

10.2.4   Abstract base class versus concrete base class

10.3   Enable polymorphism by overriding methods

10.3.1   Polymorphism with classes

10.3.2   Binding of variables and methods at compile time and runtime

10.3.3   Polymorphism with interfaces

10.4   Reference variable and object types

10.4.1   Using a variable of the derived class to access its own object

10.4.2   Using a variable of a superclass to access an object of a derived class

10.4.3   Using a variable of an implemented interface to access a derived class object

10.4.4   Binding of variables and methods at compile time and runtime

10.4.5   The need for accessing an object using the variables of its base class or implemented interfaces

10.5   Casting

10.5.1   How to cast a variable to another type

10.5.2   Need for casting

10.6   Use this and super to access objects and constructors

10.6.1   Object reference: this

10.6.2   Object reference: super