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
How can we create a thread in java?
What is the size of int?
What is string builder in java?
Does chrome use java?
What is exception hierarchy in java?
Why hashcode is used in java?
Explain list interface?
What is qms certification?
What is the difference between preemptive scheduling and time slicing?
How do you insert a line break?
how to open and edit XML file in Weblogic???
In a program, initializing an array of 100 KB is throwing an out of memory exception while there is 100 MB of memory available. Why?
Can you make a constructor final?
What is the name of the java compiler?
Name component subclasses that support painting in java programming?