Home > OS >  how do i know what kind of method is this?
how do i know what kind of method is this?

Time:10-22

I need the answer to the second question this method is of a type class, I know it isn't a constructor because it has a different name and a return type. can someone please explain to me what is it and how do we know?

this question

CodePudding user response:

A mutator is another name for a setter. It is any sort of method that changes a variable. So because it changes the value of the variable s, that makes it a mutator.

As you have already ruled out it being a constructor, you know its not answer d. However, an accessor is a method that returns private data of a class, aka a variable. If the method returned variable s, then it would be an accessor as well as a mutator. Instead, it returned the instance of the class itself which does not qualify.

  • Related