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
Does sprintf allocate memory?
What is the difference between jdk, jre, and jvm?
What are dot operator queries?
Why is static used?
What is the final keyword denotes?
Explain the scope of a variable.
I want to re-reach and use an object once it has been garbage collected. How it's possible?
What does snprintf return?
How objects of a class are created if no constructor is defined in the class?
Is null a value?
Will minecraft java be discontinued?
What is data string?
What are the six ways to use this keyword?
When is the finally clause of a try-catch-finally statement executed?
What is singleton class example?