What is meant by constructor?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can java arraylist hold different types?

496


What is stringwriter?

539


How strings are created in java?

568


Can a string be null?

544


What are the skills required for core java?

543






How can you set an applet’s height and width as a percentage?

515


What if I write static public void instead of public static void in java?

579


Why parameters should be passed by reference?

502


Why do we need hashset in java?

503


Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?

581


Can java cast null?

599


What is the purpose of checked and unchecked exceptions in JAVA?

568


How do you implement singleton class?

518


what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread

563


Explain about transient variables in java?

645