Professional Documents
Culture Documents
Q1. Write a program to print the area of a rectangle by creating a class named 'Area'
taking the values of its length and breadth as parameters of its constructor and having a
method named 'returnArea' which returns the area of the rectangle. Length and breadth
of rectangle are entered through keyboard.
CODE:
package com.company;
}
public void getarea(){
System.out.println("Area= " +setDim());
}
public static void main(String[] args){
Area x=new Area(7,5);
x.getarea();
}
OUTPUT: