What is meant by constructor?

Answer Posted / ravina gaikwad

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 ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the old name of java?

496


What is a default constraint?

603


When we serialize an object does the serialization mechanism saves its references too?

495


What are 5 boolean operators?

606


What is the difference between variable declaration and variable initialization?

492






What is difference between hashset and hashmap?

542


What is finally block?

555


How do you convert an int to a double in java?

584


What is polymorphism and what are the types of it?

486


Is java a compiler?

557


What does java se mean?

581


Explain about oops concepts.

621


What is a boolean in java?

569


What is complexity in java?

505


Explain about narrowing conversion in java?

558