Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is the use of Getters and Setters method ?

Answers were Sorted based on User's Feedback



What is the use of Getters and Setters method ?..

Answer / marshallsudhan

Before get into the answer, we gotta know something
prior...! "JavaBeans".
JavaBeans are java classes that have properties. For our
purpose, think of properties as private instance variables.
since they're private, the only way they can be accessed
from outside of their class is through 'methods'in the
class.
The methods that change a propertiy's value are called
setter methods, and the methods that retrieve a property's
value are called getter methods.

Is This Answer Correct ?    54 Yes 8 No

What is the use of Getters and Setters method ?..

Answer / 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

What is the use of Getters and Setters method ?..

Answer / adarsh gowda

Getter and setter methods are used to retrieve and manipulate private variables in a different class. A "getter" method does as it name suggest, retrieves a the attribute of the same name. A setter method allows you to set the value of the attribute.

Is This Answer Correct ?    3 Yes 1 No

What is the use of Getters and Setters method ?..

Answer / amol patil

That means you should use set<yourPropertyName> for methods
that can modify
a property (normally a property maps directly to an instance
variable, but not
necessarily) and get<yourPropertyName> for methods that can
read a property.
For example, a String variable name would have the following
getter/setter methods:

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More Core Java Interview Questions

Detail discussions on JVM, memory management and garbage collector.

0 Answers   Expedia,


Name the types of mouse event listeners ?

2 Answers  


Can multiple catch statements be used in exceptions ?

6 Answers   Wipro,


which method throws exception of type Throwable

2 Answers  


What is difference between core java and java ee?

0 Answers  


What are batch updates. in jdbc

2 Answers   Corent Technology,


Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?

0 Answers   Akamai Technologies,


What is variable explain?

0 Answers  


What is string length in java?

0 Answers  


Explain what is Marker interface?

0 Answers   BirlaSoft,


GoldMansachs Interview process....

1 Answers   Goldman Sachs,


What is object cloning in Java?

0 Answers   SwanSoft Technologies,


Categories