Question: 1. Please Create a base class: Car (1) Create private fields: name, engine (boolean), cylinder (int), wheel (int). (2) Create getters for each field (3)
1. Please Create a base class: Car (1) Create private fields: name, engine (boolean), cylinder (int), wheel (int). (2) Create getters for each field (3) Constructor should initialize cylinder(number of) and name, and set wheel to 4 and engine to true. Cylinder and name would be passed parameters (4) Create three additional methods (a) public String startEngine(): return Car -> start engine (getClass().getName() + -> Start Engine) (b) public String applyBrake(): return Car -> brake (c) public String speedUp(): return Car -> speed up 2. Please create two sub classes derived from base class Car. Each sub class should has the following functionalists: (1) Constructor with two parameters (cylinder, name): please use super constructor. (2) Override startEngine() method (3) Override applyBrake() method (4) Override speedUp() method 3. Please create a driver class to test your classes. Create objects for all of your sub classes, and each object should call the override methods. 4. Put all classes in the one java file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
