ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
What is the use of Getters and Setters method ?
 Question Submitted By :: Sankar Raj
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the use of Getters and Setters method ?
Answer
# 1
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 ?    8 Yes 6 No
Sumit Bansal
 
  Re: What is the use of Getters and Setters method ?
Answer
# 2
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 ?    10 Yes 2 No
Marshallsudhan
 
 
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
In what circumstances, compiler will supply a default constructor for a class?  4
What is stop(), suspend(), resume() method?  3
In which JDK version event-delegation model is introduced?  1
How can a class be accessed, If no access modifiers are declared?  2
Inorder to specify a container?s layout, which method is used?  1
different types of threads? TCS7
What is Ideal Design of Class?  2
Which is the best way to use for String concatenation in Java? HCL5
What are event-delegation model and event-inheritance model? Which is best?  1
Why non nested classes in java are not having marked as protected access specifier Google1
How to deprecate a method? Show it with proper example. Plz give the answer of this.Thanx in advance. mail me: tanzeem.akhtar@gmail.com  1
Adapter classes?  3
When try and catch block is used ?  6
How can be define MARKER interfce in java  1
Can you declare a static variable in a method?  4
Explain cookies?  2
Which containers may have a MenuBar?  1
What is Servlet?  8
What is ResourceBundle class?  1
How to find the length and capacity of a string buffer ?  2
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com