1interface methods{
2 public void hey();
3 public void bye();
4}
5
6//unable to implement all the abstract methods in the interface so
7// the other class automatically becomes abstract
8abstract class other implements methods{
9 public void hey(){
10 System.out.println("Hey");
11 }
12}
13
14//able to implement all the methods so is not abstract
15class scratch implements methods {
16 public void hey(){
17 System.out.println("Hey");
18 }
19 public void bye() {
20 System.out.println("Hey");
21 }
22}
1//interface declaration
2interface Polygon_Shape {
3 void calculateArea(int length, int breadth);
4}
5
6//implement the interface
7class Rectangle implements Polygon_Shape {
8 //implement the interface method
9 public void calculateArea(int length, int breadth) {
10 System.out.println("The area of the rectangle is " + (length * breadth));
11 }
12}
13
14class Main {
15 public static void main(String[] args) {
16 Rectangle rect = new Rectangle(); //declare a class object
17 rect.calculateArea(10, 20); //call the method
18 }
19}
20