Question

Explain to the best of your ability the difference between setters and getters and why we...

Explain to the best of your ability the difference between setters and getters and why we need them. -JAVA

Homework Answers

Answer #1
data members are declared as private in java.
so, that they can't be accessed/modified directly by other classes in the project.
this is called encapsulation.

but if want to allow modification, access for these members we need some other way.
that's why we create public methods to allow that.

getters, get method for the private data member, which gives the value of that data member.
setters, set method to change that private member, which sets the value of that data member.
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
explain why we need mesh(discretization) in CFD what is the difference between finite difference method and...
explain why we need mesh(discretization) in CFD what is the difference between finite difference method and finite volume difference? in ANSYS CFX which method is using?
To the best of your ability, explain in words why the memoryless property does not apply...
To the best of your ability, explain in words why the memoryless property does not apply to the following random variable types specifically: • Binomial random variables • Poisson random variables • Pascal random variables
Explain why do we need to do the Evaluation/Assessment. Please explain with all your supporting ideas...
Explain why do we need to do the Evaluation/Assessment. Please explain with all your supporting ideas to justify them.
1)    Explain what is the difference between real and nominal GDP? 2 ) and explain why do...
1)    Explain what is the difference between real and nominal GDP? 2 ) and explain why do economists need to make this distinction? 3)   Is the CPI a biased measure of the inflation rate? Explain your answer.
is there a difference between morals and ethics? why or why not? EXPLAIN IN DETAIL
is there a difference between morals and ethics? why or why not? EXPLAIN IN DETAIL
Explain in your own words what the similarities are between fractions and rational expressions Explain in...
Explain in your own words what the similarities are between fractions and rational expressions Explain in your own words what restricted values are, why we restrict them, and how we find them
Explain, in your own words, why probabilities are always between 0 and 1. Why can't we...
Explain, in your own words, why probabilities are always between 0 and 1. Why can't we have a probability of 1.2, or -12? Your response should be a minimum of two sentences and should use the standard conventions of written English.
Probability And Statistics Question: What is the difference between sample and population? Why we have choose...
Probability And Statistics Question: What is the difference between sample and population? Why we have choose sampling method instead of population analysis? Explain sampling procedures with suitable examples?
Explain the difference between primary and secondary markets and why secondary markets are so important to...
Explain the difference between primary and secondary markets and why secondary markets are so important to businesses that need to raise capital? Give examples from the real world? Please no picture, thank you
explain the difference between physiology and pathophysiology along with why it is important to understand the...
explain the difference between physiology and pathophysiology along with why it is important to understand the difference.