ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

What are the different ways to pass values to an object ?

1.Parameter : We can pass the values to a method as a parameter.
2.Constructor : We can assign the values to an object using the constructor and we can use those values in the method. Till the availability of the object we can use those values. 
 Problem : Once the object is constructed, we cant change those values.
 Advantage : If there are 2 methods then we no need to pass the values to        both of the methods. But those values are available in both the methods.
3. Setter : We can set the values using the setter approach.
  Advantage : We can change the values after constructing the object.
 When the object is constructed it contains zero and we are calling                                    setter methods to set the values.
Related Posts Plugin for WordPress, Blogger...
Flag Counter