Computer Applications
Name the different types of constructors used while defining a class.
Java Constructors
15 Likes
Answer
The different types of constructors used while defining a class are as follows:
- Parameterised constructor
- Non-parameterised constructor
Answered By
8 Likes
Related Questions
While creating a class, a specific method called constructor is defined to initialise the instance variables. Such method may or may not use parameters. In a case where the constructor is not defined in the class, the system creates on its own to put the default initial value to the instance variables. The initial values can also be duplicated from one instance to another.
Based on the above discussion, answer the following questions:
(a) Which name resembles with the constructor name?
(b) What type of constructor is used with parameters?
(c) What type of constructor initialises the instance variables with default value?
(d) Which constructor is used to duplicate the initial values from one constructor to other?
What is meant by a constructor?
Why do we need a constructor as a class member?
Explain the following terms:
Constructor with default argument