Question: Q. Understand the following program in which TeslaCars class implements interface. Compile the following program and correct the error, and also explain the reason why
Q. Understand the following program in which TeslaCars class implements interface. Compile the following program and correct the error, and also explain the reason why this program gives compilation error.
interface CarDrivingModes {
public void accelerationMode();
public void steeringMode();
public void regenerativeBraking();
public void ludicrous();
public void sport();
}
class TeslaCars implements CarDrivingModes {
public void accelerationMode(){
System.out.println("The Acceleration Modes are: chill, sport, ludicrous, ludicrous+");
}
public void steeringMode(){
System.out.println("The steering Modes are: comfort standard and sport");
}
public void regenerativeBraking(){
System.out.println("Standards and low");
}
}
class TeslaCarsDemo {
public static void main(String[] args) {
CarDrivingModes myTeslaCars = new TeslaCars();
myTeslaCars.accelerationMode();
myTeslaCars.steeringMode();
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
