how panache handles abstract class in java code example

Example 1: how to use an abstract class in java

interface methods{
    public void hey();
    public void bye();
}

//unable to implement all the abstract methods in the interface so 
// the other class automatically becomes abstract
abstract class other implements methods{
    public void hey(){
        System.out.println("Hey");
    }
}

//able to implement all the methods so is not abstract
class scratch implements methods {
    public void hey(){
        System.out.println("Hey");
    }
    public void bye() {
        System.out.println("Hey");
    }
}

Example 2: how panache handles abstract class in java

//interface declaration
interface Polygon_Shape {
    void calculateArea(int length, int breadth);
}
 
//implement the interface
class Rectangle implements Polygon_Shape {
    //implement the interface method
    public void calculateArea(int length, int breadth) {
        System.out.println("The area of the rectangle is " + (length * breadth));
    }
}
 
class Main {
    public static void main(String[] args) {
        Rectangle rect = new Rectangle();       //declare a class object
        rect.calculateArea(10, 20);             //call the method
    }
}

Example 3: how to create an abstract class in java

abstract class scratch{
  
}

Tags:

Misc Example