Question: Study the following Java program, determine the answer to the four questions below the code, and fill in the blanks below. 21 package aletermovestionti potic


Study the following Java program, determine the answer to the four questions below the code, and fill in the blanks below. 21 package aletermovestionti potic class shape pretected int areay public class Pectangle extesds srage of protected int perineter: privete int langth, widths public shape () t pubuic Aectangle (iat length, int width) t this. Iength = Lengthi area = it 1 perineter = Af this. width = widthy publie string disptayshape() \{ return =area =n++area + " perineter =perineter; poblic veid changeshapeFaraeeters( ) pubtic void calcartaperineter() \&. area = bi perineter = ei 3 21 peckage aidtereouestioni; publie class Using5hapes f 1 pacicage midternquestion1: poblic static void main (5tring argsi3 \{ Shape shl] = nes Shape[3]: public class Seuare extends shape it sh[e]= new Shape( ). private int sidelength; sh [1]= sew Square(1a)! public square(int si) 1 sh (2)= new Rectangle(18, 5) f public square sidelength = sti 7 pobtic 5tring displayshape() \& return =area = " + area + perineter = perineter + u side length =+ sideLength: 1 poblic void changeshapeParaneters (int ten) \{ sidelength in ten: 1 pabtic void calcareaperineter(\} f. area = sidetength o sideLength; periacter =4 is sidelength! Question 1: How many data members in total does the rectangle class have? Specify A, B, C, or D A) 2 B) 1 C) 3 D) 4 Your answer: (Specify A, B, C, or D) Question 2: Which of the following are overloaded methods in the rectangle class? A) calcAreaPerimeter B) changeShapeParameters C) changeShape D) There are no overloaded methods Your answer: (Specify A, B, C, or D) Question 3: Which of the following are overridden methods in the rectangle class? A) calcAreaPerimeter B) changeShapeParameters C) changeShape D) There are no overridden methods Your answer: (Specify A, B, C, or D) Question 4: What is the output of the UsingShapes program? A) area=0perimeter0area=100perimeter40area=50perimeter60 B) area=0perimeter0area=100perimeter40area=50perimeter30 C) area=0perimeter0area=100perimeter40sidelength=10area=50perimeter30 D) area=0perimeter0area=100perimeter40sidelength=10area=50perimeter60 E) No output since the Shape array can't hold Square and Rectangle instances Your answer: (Specify A, B, C, D, or E)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
