Can someone please help me out public class Box private dou
Can someone please help me out?
public class Box {
private double length;
private double width;
private double height;
public Box(double l, double w, double h) {
length = l;
width = w;
height = h;
}
public double getVolume() {
return length * width * height;
}
public static boolean sameVolume(Box b1, Box b2) {
return (b1.getVolume() == b2.getVolume());
}
}
Write a single statement to that would go in a separate class (like a driver program) to determine whether blueBox has the same volume as another box object called redBox. Store the result in a variable called sameVol.
Solution
Answer: sameVol = Box.sameVolume(blueBox , redBox);
By using sameVolume() thsi method we can determine whether two boxes are same or not.
Since sameVolume() this method is static, we can it by using class name Box.
Box.sameVolume(blueBox , redBox) would help to find out the result.
