A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
OCA Java SE 8 Programmer I Study Guide 1Z0-808
this week in the
Questions about java bean
Joined: Apr 30, 2011
Sep 04, 2011 05:49:29
I am having two questions, kindly answer them.
Q1: Can we have data members with default access modifier in a
Q2: Is it must to provide getter and setter methods for all the properties of a java bean or we can skip one if we don't need it?
Manoj Kumar Jain
Joined: Aug 22, 2008
Sep 06, 2011 06:31:55
Surely we can have data member with default access / public access in the Java Bean. But it's good practice to have data member as Private and get them access by getter and setter methods.
also you need not to make getter and setter method for each of the data member. But if you dont have a getter /setter method for a private data member you won't be able to access that data member.
Do not wait to strike till the iron is hot; but make it hot by striking....
Joined: Oct 13, 2005
Sep 06, 2011 09:01:17
The idea of a bean is that it has a no-arguments public constructor and public get and set methods for every field. That way it is possible to write the state of the class into an XML file and reconstruct it later.
I agree. Here's the link:
subject: Questions about java bean
mvc2 tier Arch.
component model and comnponent architecture
Entity Pool / Session Bean Pool
connection pooling in weblogic
can we use container managed transactions for any method in our java application?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015