Explain Mutator method

Mutator method: It is a method specifically designed to permit controlled modification of a private attribute of a class. By convention, we name the mutators with a set prefix obeyed by the name of the attribute being transformed. For example, the mutator for an attribute named speed would be setSpeed. By creating an attribute private, we save objects of other classes from modifying its value other than via its mutator. The mutator is capable to check the value being employed to transform the attribute and reject the modification when essential. Moreover, modification of one attribute may need others to be transformed in order to keep the object in a reliable state. A mutator technique can undertake this role. Mutators are employed both to grant safe access to the value of the private attribute and to save attributes from modification by objects of the other classes. The later goal is accomplished by selecting a suitable visibility for the mutator.

   Related Questions in Programming Languages

  • Q : How can I get an exact image in a web

    How can I get an exact image in a web page?

  • Q : Explain Synchronized statement

    Synchronized statement: It is a statement in which an object-lock should be obtained for the target object prior to the body of the statement and can be entered. Employed to enclose a critical section in order to save a race hazard.

  • Q : Platform security of S60 third Edition

    How do I know that platform security abilities my S60 3rd Edition application needs?

  • Q : What is an Object Object : It is an

    Object: It is an instance of a particular class. In common, any number of objects might be constructed from a class definition. The class to which an object belongs states the common characteristics of all instances of that class. In those characteris

  • Q : Define the term Dynamic type Define the

    Define the term Dynamic type: This type of an object is the name of the class employed to construct it.

  • Q : What is Class header Class header : It

    Class header: It is a header of class definition. The header provides a name to the class and states its access. It too explains whether the class expands a super class or implements any interfaces.

  • Q : Introduction to C plus Give a brief

    Give a brief Introduction to C++. Also write its features.

  • Q : Define the term Array Define the term

    Define the term Array: It is a fixed-size object which can hold zero (0) or more items of the array's declared type.

  • Q : What is Behavior Behavior : It is the

    Behavior: It is the methods of a class which implement its behavior. A particular object's behavior is a mixture of the method definitions of its class and the present state of the object.

  • Q : Create an applet of bounces in JAVA

    Create an applet that bounces a blue ball inside an applet using Thread.  The ball (diameter is 10) will start at position (0,0).  When the ball hits the edge of the applet, the ball should bounce off the edge at a randomly selected angle between 20 and 60 d

©TutorsGlobe All rights reserved 2022-2023.