Complete the code to declare an abstract class in Java.
public [1] class Vehicle { abstract void start(); }
The keyword abstract is used to declare an abstract class in Java.
Complete the code to declare an abstract method inside an abstract class.
public abstract class Animal { public [1] void sound(); }
The keyword abstract is used to declare a method without a body inside an abstract class.
Fix the error in the code by completing the class declaration to use abstraction properly.
public [1] class DisplayClass { abstract void display(); }
The class must be declared abstract if it contains abstract methods.
Fill both blanks to complete the code that shows why abstraction is required by hiding details.
abstract class [1] { abstract void [2](); } class Car extends Vehicle { void start() { System.out.println("Car started"); } }
The abstract class is named Vehicle and the abstract method is start to hide implementation details.
Fill all three blanks to complete the code demonstrating abstraction by hiding complex details.
abstract class [1] { abstract void [2](); } class [3] extends Device { void operate() { System.out.println("Device operating"); } }
The abstract class is Device, the abstract method is operate, and the subclass is Smartphone demonstrating abstraction.