The following code shows A Java Program to Compute and Display Area of a Rectangle.

// Create a simple program to find out area of a rectangle
import java.io.*;
class Rectangle
{
    int length, breadth;
    public void getDimensions() throws IOException
    {
        System.out.println("Enter the length of rectangle...");
        BufferedReader mybuffer=new BufferedReader(new InputStreamReader(System.in));
        length=Integer.parseInt(mybuffer.readLine());
        System.out.println("\nEnter the breadth of rectangle...");
        mybuffer=new BufferedReader(new InputStreamReader(System.in));
        breadth=Integer.parseInt(mybuffer.readLine());
    }
    public void findArea()
    {
        System.out.println("\nArea of the rectangle comes out to be "+(length*breadth)+" Units!");
    }
}
public class Main
{
	public static void main(String[] args) throws IOException {
		Rectangle rectOb=new Rectangle();
		rectOb.getDimensions();
		rectOb.findArea();
	}
}

Output

Find Area of a Triangle
Find Area of a Triangle

Further Reading

Understanding Enterprise Java Beans

Java Practice Exercise