Answer Posted / bindhu
Constructor is special type of member function that will
automatically invoke when an object creates. The purpose of
constructor is for the initialization of instance
variables. A constructor having the same name as that of
class name. It may have arguments but doesn't return
anything.
If we want to initialize all objects of the same class
with same values, use default constructor.Otherwise, we can
use parameterized constructor if we want to initialize
objects of the same class with different values. If we
don't specify any constructor , compiler will use default
constructor with garbage value.
| Is This Answer Correct ? | 35 Yes | 4 No |
Post New Answer View All Answers
What is the use of static class?
What is difference between arraylist and list in java?
Write a program to calculate factorial in java?
Is alive method in java?
Write a code to show a static variable?
Explain scope or life time of local variables in java?
What is meant by null and void?
What is an immutable class? How to create an immutable class?
What is static class
Is static variable stored in heap?
Explain about class in java?
What do you mean by stream pipelining in java 8?
Explain enumeration in java?
What is __ init __ functions?
What is core java called?