014-003-012
Inheriting Engine Specs with Parameterized super()
Medium
Problem Description
Inheriting Engine Specs with Parameterized super()
In this problem: You will create a program where a Car class inherits from a Vehicle class and uses a parameterized super() call to initialize the parent constructor.
Learning Objective: Understand how to initialize a parent class using super() with multiple arguments
Overview
The Vehicle class manages the maker name and year. The Car class extends Vehicle and adds engine displacement (cc). The Car constructor calls super(maker, year) to initialize the parent fields, then sets its own field.
Specifications
Vehicleclass:maker(String),year(int) fields, constructor, getter methodsCarclass: extendsVehicle, addsengineCC(int) fieldCar(String maker, int year, int engineCC)constructor callssuper(maker, year)getInfo()method returns vehicle information
Output Format
Maker: Toyota
Year: 2024
Engine: 2000cc
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