why the constructor should be used in class,if there is no
constructor what will happen?

Answer Posted / bindhu

In Java, initialization of every object possible
by providing a constructor. If a class has a constructor,
Java automatically calls that constructor when an object is
created. So initialization is guaranteed.

If we don't define a constructor for a class, a default
parameterless constructor is automatically created by the
compiler.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a finally block?

767


What is Hierarchy of exception?

854


What is the difference between pass by reference and pass by pointer?

722


What is java util list?

676


Compare overloading and overriding?

801


How many bits is a double?

759


What are loops in java?

798


What is difference between == equals () and compareto () method?

751


What is the difference between && and & in java?

824


What is the program development process?

755


What sorting algorithm does javascript use?

762


Difference between arraylist and vector.

830


Why javac is not recognized?

722


What does java final mean?

734


Is age a discrete variable?

743