Java Program using abstract class and interface
In this program, You will learn how to implement abstract class and interface in java.
interface Clerk {
//declaration
}
abstract class Peon implements Clerk {
//statement
}
class Admin extends Peon {
//statement
}
Example: How to implement abstract class and interface in java.
interface Clerk {
int csal = 10000;
}
abstract class Peon implements Clerk {
int psal = 8000;
abstract void add();
}
class Main extends Peon {
int tsal;
void add() {
tsal = csal + psal;
System.out.println("Clerk Salary is :" + csal);
System.out.println("Peon Salary is :" + psal);
System.out.println("Total Salary is :" + tsal);
}
public static void main(String args[]) {
Main ad = new Main();
ad.add();
}
}
Output:
Clerk Salary is :10000
Peon Salary is :8000
Total Salary is :18000