Answer Posted / sumit bansal
you can put verification code in setter as if you want a
variable for storing weight you never want weight -ve So
write the code that prevent -ve entry of varible value in
setter method
Using getter and making your variable private you can be
sure that nobody can access it directly from outside.
| Is This Answer Correct ? | 31 Yes | 19 No |
Post New Answer View All Answers
What is a percentage sign called?
Can a class be protected in java?
Can we able to pass objects as an arguments in java?
Why hashcode is used in java?
What is bifunction in java?
What are constants?
What is a arraylist in java?
What are the types of web technologies?
What is bigger kb or mb?
Can we override private constructor in java?
What is meant by inheritance and what are its advantages?
Can we call a non-static method from inside a static method?
What is meant by 'bit masking' in java?
Explain when classnotfoundexception will be raised ?
Difference between error and exception