What is meant by constructor?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is user defined exception in Java?

619


What is a priority queue java?

530


What is collection class in java? List down its methods and interfaces.

536


How big is a 32 bit integer?

539


What is a war file?

559






What is a java predicate?

541


What is class variable java?

594


What is a buffer in java?

577


How to call one constructor from the other constructor ?

617


Explain Basics of OOP Language in java

598


What is native method in java?

575


What is meant by vector class, dictionary class, hash table class, and property class?

691


What is entry in java?

541


What is java algorithm?

529


What is nested class?

579