Given the following class import java.util.ArrayList; public class RectangleTester { public static void main(String[ ] args) { ArrayList shapes = new ArrayList(); shapes.add(new Rectangle(1, 1)); shapes.add(new Rectangle(2, 2)); shapes.add(new Rectangle(3, 3)); shapes.add(new Rectangle(4, 4)); Rectangle dataRecord; for(int index = 0; index < shapes.size(); index++) { dataRecord = shapes.get(index); dataRecord.calcRectArea(); dataRecord.calcRectPerimeter(); } } } Which of the following could not be a constructor for the RectangleClass? I. Rectangle(int s1, int s2) { mySide1 = s1; mySide2 = s2; } II. Rectangle(s1, s2) { mySide1 = s1; mySide2 = s2; } III. Rectangle() { }

Respuesta :

We didn't need to see all that code to know that answer.


I. Rectangle(int s1, int s2) { }
is a valid constructor

II. Rectangle(s1, s2) { }
is an invalid constructor, as the data type for s1 and s2 was not specified.

III. Rectangle() { }
is a valid constructor, as it is simply the default constructor.