(5 points) All of the method calls in 4b - e are currently non-static. If the me
ID: 3704678 • Letter: #
Question
(5 points) All of the method calls in 4b - e are currently non-static. If the methods were changed to be static, you would need to change one word in each method call Which word would you change, and what would you change it to? 5. (5 points) Given an object named rectangle, constructed elsewhere, call the setter method to set the instance variable height to 3. You will only need to include the one method, do not worry about constructing the object or any other component of the code. 6. (5 points) Given an object named square, constructed elsewhere, call the setter method to set instance variables length to 6. Again, do not worry about constructing the object or any other component of the code. 7.Explanation / Answer
Hi, Please rate by thumbs up, if answer is clear to you.
Thank you
Q 5,) If the methods are declared as static , then we need to change the object and replace it with class name because static methods are called as classname. method() and not object.method()
Q 6.
public static void setheight(int h)
{
this.h =h;
}
classname.setheight(3);
Q7.
public static void setlength(int l)
{
this.l =l;
}
classname.setlength(3)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.