tampurus

45 Interface shape and implemented areas of figures

May 9th, 2022 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.io.*;
  2. interface shape{
  3.     int length=3,breadth=6,side = 6;
  4.     void AreaOfSqure();
  5.     void AreaOfRectangle();
  6. }
  7. class Main implements shape{
  8.     public void AreaOfSqure(){
  9.       System.out.println("Area of Square is " +side*side);
  10.     }
  11.     public void AreaOfRectangle(){
  12.       System.out.println("Area of Rectangle is " + length*breadth);
  13.     }
  14.     public static void main (String args[]){
  15.         Main obj = new Main();
  16.         obj.AreaOfRectangle();
  17.         obj.AreaOfSqure();
  18.     }
  19. }
  20. /*
  21. Area of Rectangle is 18
  22. Area of Square is 36
  23. */
Add Comment
Please, Sign In to add comment