answersLogoWhite

0

Define the java terms of accessor?

Updated: 12/13/2022
User Avatar

Wiki User

15y ago

Best Answer

Accessors are methods defined inside classes to access the private variables of the class. It is always a good practice to have instance variables as private so that, other classes cannot access them directly. This would avoid unwanted modification of data. These variables can be accessed only via their respective accessor methods. Ex: public class Test { private String name = ""; public String getName(){ return this.name; } Public void setName(String val){ this.name = val; } } Here getName and setName are the accessor methods for the variable name.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Define the java terms of accessor?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you define variables in interface in java?

yes we can define a variable in an interface in java.


Are accessor member functions a sign of poor class design?

No, accessor member functions are a sign of good class design, particularly in terms of data encapsulation.


Define set in java?

A Java set is a collection of things that do not contain duplicate elements. Duplicates are prohibited from Java sets.


What is the hierarchy of the java program?

define the data types


Define 'want' in busines terms?

define 'Want' in marketing terms


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.


Why does java have a coffee table as icon?

Java is one of the slang terms for coffee.


What is an accessor?

An accessor is a method in a Java Bean that is used to access the private variables of the class. Usually instance variables in a bean are declared as private and they can be accessed only via these accessor methods. Ex: public class Employee { private String name = ""; private int age = 0; public String getName(){ return this.name; } public void setName(String nm){ this.name = nm; } public int getAge(){ return this.age; } public void setAge(int ag){ this.age = ag; } } In the above example name and age are instance variables and the methods beginning with get and set are the accessor methods.


How do you uss static in java?

It is uss to define class and method of pogrom's.


Name two high level languages and define them?

Java C++


Is java virtual machine dangerous?

JVM is a critical component in almost all Java platforms. I would hardly define it as "dangerous".


In computer terms what does the phrase 'java string replace' mean?

When referring to computer terms, the phrase "java string replace" means that a string in the line of code that Java uses, is being replaced, or needs to be replaced.