Designed a class that demonstrates the use of constructor and destructor. | VCMIT

by - March 13, 2020

Constructor And Destructor.


INPUT

class Square{
int width,height;
Square( int a , int b){
width = a;
height = b;
}
int area(){
return width * height;
}
}
class Cal{
public static void main(String[] args){
{
Square s1 = new Square(10,20);
int area_of_sqaure = s1.area();
System.out.println("The area of square is:" + area_of_sqaure);
}
}
}

OUTPUT



You May Also Like

0 Comments