Respuesta :
Answer:
Option D void setAge(int newAge);
Explanation:
In object oriented programming, mutator method is defined to change the value of the data member(s) in the class. Since the mutator method is aimed to change the value of a class data member, it is required to take in one new value as parameter to overwrite the existing value of data member. The mutator doesn't return any output. Hence, the best declaration for a mutator method to change the age is
void setAge(int newAge);
The new value of age is passed to parameter newAge and the void means the method doesn't return any value as output.
A mutator process is chosen in the OOP language and can modify the value of a class's data member(s). In this question, the mutator function is intended to modify the number of a class data function that accepts a new value as an argument to overwriting the data member's current value.
- There is no output from the mutator, and as a result, the ideal declaration of e mutator function that alters the age is "void setAge(int newAge);".
- A new age value is supplied to the newAge parameter, and the void indicates that the procedure does not return any value as output.
- Therefore, the final answer is "
- Option D
- ".
Learn more:
brainly.com/question/13991636