publicclass Box { publicstatic void methodone() { intlength = 5; int width = 0;
ID: 3608141 • Letter: P
Question
publicclass Box
{
publicstatic void methodone()
{
intlength = 5;
int width = 0;
int height = 0;
System.out.print("Line created");
}
publicstatic void methodtwo()
{
intlength1 = 3;
int width2 = 2;
int height3 = 0;
System.out.print("Rectangle Created");
}
publicstatic void methodthree()
{
intlength4 = 7;
int width5 = 8;
int height6 = 9;
System.out.print("Box created");
}
}
classTestBox
{
publicstatic void main(String args[])
{
Box methodone = new Box();
Box methodtwo = new Box();
Box methodthree = new Box();
System.out.println("The length, width, and height of argument one is" + methodone.length +methodone.width + methodone.height);
System.out.println("The length, width, and height of argument two is" + methodtwo.length1 +methodtwo.width2 + methodtwo.height3);
System.out.println("The length, width, and height of argument three is" + methodthree.length4 +methodthree.width5 + methodthree.height6);
}
}
Explanation / Answer
I'm breaking this into two responses. First is the Boxclass: public class Box{ public int length; public int width; public int height; Box(int x){ length = x; width = 0; height = 0; System.out.println("Line created");} Box(int x, int y){ length = x; width = y; height = 0; System.out.println("Rectangle Created");} Box(int x, int y, int z){ length = x; width = y; height = z; System.out.println("Box created");} }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.