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

1. Find the error in the following class: public class TwoValues { private int x

ID: 3529398 • Letter: 1

Question

1. Find the error in the following class: public class TwoValues { private int x, y; public TwoValues() { x = 0; } public TwoValues() { x = 0; y = 0; } } 2. Consider the following class declaration: public class Square { private double sideLength; public double getArea() { return sideLength * sideLength; } public double getSideLength() { return sideLength; } } a. Write a no-arg constructor for this class. It should assign the sideLength field the value 0.0. b. Write an overloaded constructor for this class. It should accept an argument that is copied into the sideLength field.

Explanation / Answer

1.public class MyClass { private int x; private double y; public static void setValues(int a, double b) { x = a; y = b; } } I thought a static method can't manipulate variables from the same class. Static methods typically take all they data from parameters and compute something from those parameters, with no reference to variables