Ask Question
10 August, 22:11

Assume that you have created a class named Dog that contains a data field named weight and an instance method named setWeight (). Further assume that the setWeight () method accepts a numeric parameter named weight. Which of the following statements correctly sets a Dog's weight within the setWeight () method? a. weight = weight

b. this. weight = this. weight

c. weight = this. weight

d. this. weight = weight

+1
Answers (1)
  1. 10 August, 22:54
    0
    D) this. weight = weight

    Explanation:

    since a constructor call in java sets the initial value for variable, using the this.

    in this way, refers to the current object in a method or constructor.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assume that you have created a class named Dog that contains a data field named weight and an instance method named setWeight (). Further ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers