What is the use of Getters and Setters method ?

Answer Posted / adarsh gowda

Getter and setter methods are used to retrieve and manipulate private variables in a different class. A "getter" method does as it name suggest, retrieves a the attribute of the same name. A setter method allows you to set the value of the attribute.

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of static methods?

581


How do you remove an element from an arraylist in java?

458


What are methods in java?

534


what is difference between equals and ==?

584


How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters?

581






Why arraylist is not synchronized in java example?

463


What do you mean by chromounits in java8?

524


Differentiate between run time error and syntax error.

563


How do you sort arrays in java?

519


What is set and get methods in java?

534


Lowest Common ancestor in a Binary Search Tree and Binary Tree.

551


How to sort an array from smallest to largest java?

538


Can you explain the private protected field modifier?

565


How would you convert bytes to string?

556


Tell me the latest versions in java related areas?

576