Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


What is meant by constructor?

Answers were Sorted based on User's Feedback



What is meant by constructor?..

Answer / 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

What is meant by constructor?..

Answer / dinesh

All the objects that are created must be given initial
values.There are two approach for this.
1)Using the dot operator to access the instance variables
and then assign values to them individually---This is a
tedious approach.
2)Use of getData method to initialize each object
individually.eg:add.getData(10,15)
To make this simpler Java supports a special type of method
called a Constructor,that enables an object to initialize
itself when it is created.Constructor have the same name as
the class itself and they do not specify a return type,not
even void,bcoz they return the instance of the class itself.

Is This Answer Correct ?    23 Yes 4 No

What is meant by constructor?..

Answer / onkdurga

constructor is a special type of member function,which has
the class name as function name.constructors doesn't have
any return type even void.constucter can be called
automatically at the time of object creation.Generally it
is used for initializing values to the data members.

constructorsare2types:1.default/parameterless
constructor
2.parametarized constructor

*costructor can not be inherited
*constructor can not be declared as static
*constructor can not be accessed outside of the class when
it is specified as private.

Is This Answer Correct ?    13 Yes 2 No

What is meant by constructor?..

Answer / ravikiran(aptech mumbai)

constructor is the one which is used to pass the
initializing parameters during instantiation

Is This Answer Correct ?    9 Yes 3 No

What is meant by constructor?..

Answer / ajay yadav

Constructor is defined as a type of member function which
calls itself when an object is created also has the same
name as of the class.

Is This Answer Correct ?    9 Yes 3 No

What is meant by constructor?..

Answer / suman blazta

Constructors are used to create and initialize objects of their class type.
Constructor is a special member function that takes the same name as the class name.The constructor is automatically named when an object is created. A constructor is named whenever an object is defined or dynamically allocated using the "new" operator.

Is This Answer Correct ?    4 Yes 0 No

What is meant by constructor?..

Answer / shiva

java allows objects to initilize themselves when they are
created .this automatic initilization is done wih the use
of constructor .a constructor is a special type of method
that has the same name of its class.when ever an object of
class is created,its constructor will be invoked and it
will initilized the object.the return type for a
constructor is not defined as it implicitly takes its class
type as return type.

Is This Answer Correct ?    5 Yes 5 No

What is meant by constructor?..

Answer / 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



More Core Java Interview Questions

Where is stringbuffer stored?

0 Answers  


What is type safety in java?

0 Answers  


Can a final method be overloaded?

0 Answers  


What do you mean by JVM?

0 Answers   Ericsson,


Is string pool garbage collected?

0 Answers  






What is pojo class in java?

0 Answers  


what is difference between abstraction and interface?

8 Answers   FIC,


what is mean by String and StringBuffer? What is mean by Methooverriding and Overloading?

3 Answers   Satyam, STI,


What is object-oriented programming?

0 Answers  


Is hashset ordered?

0 Answers  


How to make a method thread safe without using synchronized keyword?

8 Answers   Persistent, Societe Generale,


What is a java list?

0 Answers  






Categories