Computer Applications
For which purpose a constructor is used?
- To initialise the instance variables
- To provide the instance variables
- To organise the instance variables
- To simplify the instance variables.
Java Constructors
48 Likes
Answer
To initialise the instance variables
Reason — A constructor is used to initialise data members with default or user-defined values at the time of creation of an object.
Answered By
28 Likes
Related Questions
Which of the following statements is false?
- A constructor has same name as class name.
- A constructor returns initial value.
- A constructor is called while creating an object.
- A constructor is not used for arithmetical and logical operations.
A constructor is always:
- private
- protected
- secure
- public
Which constructor initialises data members with default values?
- Parameterized constructor
- Non-parameterized constructor
- Copy constructor
- Default constructor
What is not true for a constructor?
- It is used only to initialize the data members.
- It returns a unique value.
- It may not use parameter.
- None of the above.