Question: Q.3 Consider the following interface Vehicle. (Marks:3) interface Vehicle { void changeGear(char newGear); void increaseSpeed(int newSpeed); void decreaseSpeed(int newSpeed); 3 a) Create the classes Car
Q.3 Consider the following interface Vehicle. (Marks:3) interface Vehicle \{ void changeGear(char newGear); void increaseSpeed(int newSpeed); void decreaseSpeed(int newSpeed); 3 a) Create the classes Car and Bus that implements the methods of interface Vehicle. b) Add gear and speed fields in Car and Bus classes. c) changeGear() method sets the gear field by newGear value. d) increasespeed() method increases the speed field by newSpeed value. e) decreaseSpeed() method decreases the speed field by newSpeed value. Q.4 Can an abstract class have concrete (non-abstract) methods? Can a concrete class have abstract methods? Can you have an abstract class without abstract methods? Justify your answers. (Marks:2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
