Last active
May 20, 2021 04:55
-
-
Save Aroueterra/e3e6dd3965fcb7c8cb7d05a8ac5288e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestClass { | |
private String color; | |
public TestClass(String c) { | |
color = c; | |
} | |
// In getter, returnColor should return String | |
public void returnColor() { | |
return color; | |
} | |
// No return statement error (setter should actually be void) + newColor should not be a method call | |
public String changeColor(String newColor) { | |
color = newColor(); | |
} | |
} | |
public class LabQuestion { | |
public static void main(String[] args) { | |
TestClass myObject = new TestClass("red"); | |
myObject.changeColor("blue"); | |
System.out.println(myObject.returnColor()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment