java program for box using constructor

//program for box using constructor

import java.io.*;
import java.util.*;

class MyBox{
    double length;
    double breadth;

MyBox(double l,double b){
    length=l;
    breadth=b;
}
    double vol(){
        return length * breadth;
    }
}
class Box{
    public static void main(String args[]){
    MyBox rectangle=new MyBox(10,20);
    System.out.println(“vol is “+rectangle.vol());
}
}   
OUTPUT-
vol is 200.0

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat