by Dinesh Thakur

 

import java.io.*;

class rect
{
            int l,b;
            void setval(int x,int y)
            {
                        l=x;
                        b=y;
            }
            int area()
            {
                        return (l*b);
            }
};
class RectangleUsingClasses
{
            public static void main (String args[]) throws IOException
            {
                        BufferedReader g=new BufferedReader(new InputStreamReader (System.in));
                        String h;
                        int p,q;
                        rect k=new rect();
                        System.out.println("Enter Length and Breadth : ");
                        h=g.readLine();
                        p=Integer.parseInt(h);
                        h=g.readLine();
                        q=Integer.parseInt(h);
                        k.setval(p,q);
                        System.out.println("Area of Rectangle is :"+k.area());
            }
};

Java Example to Calculate Area of Rectangle Using Classes, Values Not Given