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 the difference between yielding and sleeping?

559


Which sorting algorithm is best in java?

537


What is the map interface in java programming?

587


What if constructor is protected in java?

562


What is the intersection and union methods?

550






How to access arraylist elements in java?

494


What is a byte string?

625


What are some characteristics of interference class?

519


What are the main differences between the java platform and other platforms?

531


what do you mean by java annotations?

551


What is the difference between import java.util.date and java .util?

572


How do you sort a string in alphabetical order in java?

537


How do I get the | symbol on my keyboard?

595


What is the difference between private & public & friendly classes?

553


What is the argument in java?

497