Computer Applications
How can objects be initialized with desired values at the time of object creation ?
Java Constructors
2 Likes
Answer
Objects can be initialized with desired values at the time of object creation by using parameterized constructor and passing the desired values as arguments at the time of creation of object.
Answered By
2 Likes
Related Questions
What are benefits/drawbacks of temporary instances ?
How do we invoke a constructor ?
When a compiler can automatically generate a constructor if it is not defined then why is it considered that writing constructors for a class is a good practice ?
'Accessibility of a constructor greatly affects the scope and visibility of their class.' Elaborate this statement.