Java Programming Chapter 4——Feature 3: Polymorphism (1)

Feature 3: Polymorphism (1)

1. Concept: the reference of parent type can point to different subclass objects.

2. Syntax: parent class name reference name = new subclass class name (argument);

Example:

Animal (reference type) a = new Cat (argument)

Animal (parent class type) a = new Cat (subclass type)