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 externalizable?

817


Write a function to print Fibonacci series and Tribonacci series?

945


Why is inheritance used in java?

822


What is a module function?

796


What is the difference between instanceof and isinstance?

754


how its run?

804


Is java developer a good career?

767


What is foreach loop in java?

748


How do you identify if jvm is 32-bit or 64-bit from java program?

726


What is a memory leak in java?

771


What are constants?

802


What is a protected method?

842


How do you initialize an arraylist in java?

733


How do I find and replace in word?

730


what are Hostile Applets?

1798