015-002-005

Upcast: Vehicle Class

Easy

Problem Description

Upcast: Vehicle class

Learning Objective: Understand upcast assigning child class object to parent class type

In this problem, you will create a program that defines a Vehicle class and a Car class, assigns a Car object to a Vehicle type variable using upcast, and displays the result to standard output.

Create a Vehicle class representing vehicles and a Car class inheriting from it. Create a Car object and assign it to a Vehicle type variable (upcast) to learn how child class objects can be handled with a parent class type.

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up