public class Test2
{ public static void main(String[] args)
{
//Shape shape = new Rectangle(1,2); Rectangle shape = new Rectangle(1,2); System.out.println("The length of rectangle is "+shape.length); System.out.println("The width of rectangle is "+shape.width); int area = shape.getArea(); System.out.println("The area of rectangle is "+area); }
}
abstract class shape
{ public abstract int getArea();}
class Rectangle extends shape
{
int length; int width; Rectangle(int length,int width)
{
this.length = length; this.width = width; }
int getArea();
{
return (this.length * this.width);
}
}java