Create Area class to extend Rectangle class
class Rectangle { float length; float breadth; Rectangle()//w w w . j a v a 2 s . c om { length = 5; breadth = 6; } } class Area extends Rectangle { public float calculate() { return length * breadth; } } class Single_Level { public static void main(String args[]) { Area a = new Area(); System.out.println("Area = " + a.calculate() + " square meters"); } } /* Output Area = 30 square meters */