Creating abstract classes
For people who love cars, hearing the horn is all they need to identify a particular type of car. Many car manufacturers know this and make their cars sound unique as a branding strategy. You will update the Car class to contain a method for the horn functionality of cars.
NOTE: An abstract class cannot have instance objects created from it, as it exists to be merely a blueprint from which to be inherited.
Diese Übung ist Teil des Kurses
Introduction to Object-Oriented Programming in Java
Anleitung zur Übung
- Make the
Carclass an Abstract class using theabstractkeyword. - Create a
publicabstractvoidmethod insideCarcalledsoundHorn.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
public class Main {
// Make Car abstract
static ____ class Car {
public Car() {
}
// Define soundHorn() as a public abstract void method
public ____ ____ ____();
}
public static void main(String[] args) {
}
}