Question: JAVA PROGRAMMING Which of the following code fragments are the correct way of implementing toString method for the Point class presented in the textbook? Select
JAVA PROGRAMMING Which of the following code fragments are the correct way of implementing toString method for the Point class presented in the textbook? Select all that apply.
public void toString() {
System.out.println( "(" + x + ", " + y + ")");
}
public String toString() {
String representation = "class Point: (" + x + ", " + y + ")";
return representation;
}
public String toString() {
return "(" + x + ", " + y + ")";
}
public String toString(int x, int y) {
return "(" + x + ", " + y + ")";
}
public static String toString() {
return "(" + x + ", " + y + ")";
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
