Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given a Box class below, what would be the outputs of the three println statemen

ID: 3883897 • Letter: G

Question

Given a Box class below, what would be the outputs of the three println statements in the class MyProg? public class Box { int length, width, depth: public Box (int l, int w, int d) { length = l: width = w: depth = d: } public Box(Box b){ length = b.length: width = b.width: depth = b.depth: } public int getVolume(){ return length * width * depth: } } public class MyProg{ public static void main(String[] args){ Box b1 = new Box(3, 4, 5): Box b2 = new Box(b1): Box b3 = b1: System.out.println(b1.getVolume()+","+ b2.getVolume()+","+ b3.getVolume()): b1.length = 6: System.out.println(b1.getVolume()+","+ b2.getVolume()+","+ b3.getVolume()): b3.width = 7: System.out.println(b1.getVolume()+","+ b2.getVolume()+","+ b3.getVolume()): } } printlin 1 - println 2 - println 3 -

Explanation / Answer

Print1 - 60,60,60 (lenth = 60, width = 60, depth = 60)

Print2 - 120,60,120 (lenth = 120, width = 60, depth = 120)

Print3 - 210,60,210 (lenth = 210, width = 60, depth = 210)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote