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 a conditional equation?
Difference between operator overloading and function overloading
What is the concept of multithreading?
What are design patterns and please explain?
What are the advantages of passing this into a method instead of the current class object itself?
What is the difference between class forname and new?
How an object is serialized in java?
Which is best ide for java?
Does treeset allow null in java?
Why does java not support pointers?
Can we convert stringbuffer to string?
What is the symbol for line break?
How many JVMs can run on a single machine and what is the meaning of Just-In-Time (JIT) compiler?
Can a class be private or protected in java?
How do I get the | symbol on my keyboard?