I am newbie in J2EE & looking for strong basic behind each
concept as,
Why do we use private access specifier before each variable
of
type property bcoz ultimately to access it outside the class
we use public method as getter & setter ?

If we use getter & setter to access it outside the class so
better we make variable as public so that it is easily
available outside of the class...

Please guide me why do we use as private ????

Answer Posted / srinivaskumar.nimmana

Here data is very important, data means variable.. if our class variable are need access by several classes because of that classes code may corrupt our classes code because of our data directly available to that classes, so we need secure to our data that's why we declare as private variables

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is java ee used for?

444


How can I be good in java?

516


Is java gui dead?

501


What is a thin client?

571


What is jbutton in java?

498






Describe action form?

523


What is meant by applet in java?

461


Is java 100 percent pure object oriented?

499


On which platform j2ee is based?

521


Why java is oop language?

539


Is python more secure than java?

553


What every java developer should know?

467


What is java gui?

499


What are the j2ee technologies?

483


What is wildfly java?

478