Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members

Multiple constructors

Exploring constructors in a Rectangle class

Report a typo

Consider the following Java code for the class Rectangle:

public class Rectangle {
  private int length;
  private int width;

  public Rectangle(int length, int width) {
    this.length = length;
    this.width = width;
  }

  public Rectangle(int size) {
    this(size, size);
  }
}

Which of the following statements are true?

Select one or more options from the list
___

Create a free account to access the full topic