Using the above image I need help with the below. Thanks. Provide the definition
ID: 3911288 • Letter: U
Question
Using the above image I need help with the below. Thanks.
Provide the definition of the toString method for the class shown in the image.
Q1: The composed string should have the following format where value_of_x means that actual value stored in x and everything else should be produced as listed.
a: value_of_a, b: value_of_b
For example, if a has a value of 3 and b has a value of 10, the format should be a: 3, b:10.
Q2:Provide a piece of code that would display an instance e of the class shown in the image by utilizing its toString method.
C Exam Exam(Exam) ?? Exam(int) G , Exam(int, int) findS() : void getB() : int o setB(int) void :VOExplanation / Answer
1)
public String toString() {
return "a: " + a + ", b: " + b+".";
}
2)
Exam e = new Exam(3,10);
System.out.println(e);
Thanks, PLEASE UPVOTE if helpful. Let me know if there is any concern.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.