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


Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation