Challenge 2: Calling a Constructor from a Constructor
Can you call a constructor from another constructor? A solution is placed in the "solution" section to help you, but we would suggest you try to solve it on your own first.
We'll cover the following
Problem Statement
A class can have multiple parameterized constructors which can call each other.
You are given a partially completed code of a Car
class in the editor. Modify the parametrized constructor which assigns parameters to the required fields.
Input
carName, carModel, carCapacity
Output
carName, carModel, carCapacity
Sample Input
"Ferrari", "F8", "100"
Sample Output
"Ferrari", "F8", "100"
Get hands-on with 1400+ tech skills courses.