prg1part2

Pasted Oct 9, 2026, 8:48 AM1 file58 lines

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/zzgt0fhpwhgm6m25
prg1part2
package Shape;

public class AbstractionDemo1 {
	public static void main(String []args) {
		Shape Circle=new Circle(5);
		Shape Rectangle=new Rectangle(4,6);
		
		Circle.display();
		Rectangle.display();
	}

}
 


}

package Shape;

class Circle extends Shape{
	private double radius;
	
	Circle(double radius){
		this.radius=radius;
	}
	
	double area() {
		return Math.PI*radius*radius;
	}

}

package Shape;

class Rectangle extends Shape {
	private double length,width;
	
	Rectangle(double length, double width){
		this.length=length;
		this.width=width;
	}
	
	double area() {
		return length*width;
	}

}

package Shape;

abstract class Shape {
	abstract double area();
	
	void display() {
		System.out.println("Area: "+area());
	}
}

737 chars · codepastes.com