Use of private variable while creating properties ???

Answer Posted / m4n07

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 ????

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 the concept of connection pooling?

541


What is application client module?

533


What is java developer?

470


What is java full stack developer?

485


What is source file in java?

511






What is java transaction service (jts)?

543


What is DDP?

537


What is event in java?

469


What is a java developer?

469


What is document?

522


What is external entity?

558


What is a jpanel in java?

492


What are the components and containers in java?

497


What is component contract?

526


Is j2ee a framework?

481