answersLogoWhite

0


Best Answer

An accessor is a method that accesses the contents of an object but does not modify that object. In the simplest case, an accessor just returns the value of one of the fields. In general, an accessor performs some computation using the fields as long as that computation does not modify any of the fields. Mutators

A mutator is a method that can modify an object. In the simplest case, a mutator just assigns a new value to one of the fields. In general, a mutator performs some computation and modifies any number of fields. Sometimes, accessors are called 'getter' methods and mutators are called 'setter' methods.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

7y ago

One of the techniques in object-oriented programming is encapsulation. It concerns the hiding of data in a class and making them available only through its methods. In this way the chance of making accidental mistakes in changing values is minimized. Java allows you to control access to classes, methods, and fields via so-called access modifiers. The access to classes, constructors, methods and fields are regulated using access modifiers i.e. a class can control what information or data can be accessible by other classes. To take advantage of encapsulation, you should minimize access whenever possible.

Java provides a number of access modifiers to help you set the level of access you want for classes as well as the fields, methods and constructors in your classes. A member has package or default accessibility when no accessibility modifier is specified.

Access Modifiers

1. Private

2. Protected

3. Default

4. Public

Public is the most liberal access modifier and Private is the most restrictive access modifier.

Note: there is no such thing as an 'access specifier' in Java, only access modifiers.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

accessor method returns value,where as mutator method doesnot return any value.

for example:

setPriority() method is mutator method ,this method present in Thread class from java.lang package

getPriority() method is accesor the method,this method also present in Thread class from java.lang package

by using setPriority() method,we can set the name to thread.

by using getPriority() method,we can retrive the name to thread

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

private, public, protected, and the default access.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Getter methods are accessor methods.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are accessors and mutator method in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is a mutator in java?

A Java method that changes the state of an object is called a mutator. Mutators typically do not return a result (are declared to return void), although some mutators both change state and return a result (e.g., nextToken in StringTokenizer). Mutators just change state, without looking at current values, are often call "setters", and their names often start with set. In computer science, a mutator method is a method used to control changes to a variable.


What method in java performs some action (i.e. not assignments) other than returning a value?

Methods that are neither mutators (setters) or accessors (getters). This primarily includes the class constructors (the initialisers) and the class destructor (the restorer).


What is overridnig method and overlording method in java?

There is no such thing as overlording in Java.


What is the task of the main method in java platform?

It is the method that gets called when a Java application is started.


How nesting of methods is done in java?

No, Java only allows a method to be defined within a class, not within another method.


What is function in java terminology?

In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.In Java, a function is called a "method". In Java as well as other languages, a method is a function defined specifically for one class. In Java, this is the only way to define functions, therefore, all functions are methods.


What is a method in Java?

A Java method is a sequence of statements. It is comparable to a function, subroutine, or procedure in other languages.


What is the purpose of NoMatchException handling method in java?

java exception


Why comparator has equals method?

The Java superclass Object says that all Java objects have an equals method. Thus Comparator has an equals method.


What is the meaning of a method in Java programming?

a method is a variable


What is the return type of finally method in java?

The final and finally keywords have no impact on the return type of a method in Java.


What is a getContentPane method in Java?

The getContentPane() method is used to get the main component in a Java Swing JFrame. It is usually a JPanel.