Advertisement
zoro-10

Pr2b.java

Mar 30th, 2024 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. abstract class Shape {
  2.  
  3.   public abstract double area();
  4. }
  5.  
  6. class Circle extends Shape {
  7.  
  8.   private double radius;
  9.  
  10.   public Circle(double radius) {
  11.     this.radius = radius;
  12.   }
  13.  
  14.   @Override
  15.   public double area() {
  16.     return Math.PI * radius * radius;
  17.   }
  18. }
  19.  
  20. public class Pr2b {
  21.  
  22.   public static void main(String args[]) {
  23.     Circle c = new Circle(10.0);
  24.     System.out.println("Area of Circle=" + c.area());
  25.   }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement