ABSTRACT CLASS:
Abstract class
The abstract keyword is a non-access modifier, used for classes and methods
Abstract class: is a restricted class that cannot be used to create objects (to access
it, it must be inherited from another class).
Abstract method: can only be used in an abstract class, and it does not have a
body. The body is provided by the subclass (inherited from).
abstract class Fruit {
// Abstract method (no body)
public abstract void taste();
// Regular method
public void color() {
[Link]("Fruits can have different colors");
class Apple extends Fruit
public void taste() {
[Link]("The apple tastes sweet and juicy");
}
class Main {
public static void main(String[] args) {
Apple myApple = new Apple(); // Create an Apple object
[Link](); // Output: The apple tastes sweet and juicy
[Link](); // Output: Fruits can have different colors