In this program we have created:
- a class: Box9
- a parameterized constructor: Box9(double x, double y, double z)
- a method: volume() where the call by reference is implemented
- a main class: Box9Demo
- an object: b1
import java.util.Scanner;
class Box9{
double w;
double d;
double h;
Box9(double a, double b,double c){
w=a;
d=b;
h=c;
}
void volume(Box9 b1){
System.out.println("volume ="+b1.w*b1.d*b1.h);
}
}
class Box9Demo{
public static void main(String args[]){
Box9 b1=new Box9(10.0,12.0,13.0);
b1.volume(b1);
}
}
0 comments:
Post a Comment