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
Does substring create a new object?
Is java 9 released?
What is listnode in java?
Can we override singleton class?
Explain the purpose of garbage collection in Java?
What is the synchronized method modifier?
Is hashset ordered java?
How do you clear an arraylist in java?
Compare overloading and overriding?
What is hashset in java?
Describe the syntax of multiple inheritance? When do we use such an inheritance?
Which is better singleton or static class?
What is static synchronization?
Can a class extend 2 classes in java?
Can we sort set in java?