Ask Question
13 December, 18:48

The main purpose of a constructor is to initialize the data members at the moment that an object is created. true or false?

+3
Answers (1)
  1. 13 December, 18:57
    0
    True

    Explanation:

    In Object Oriented Programming, a constructor is a type of subroutine whose purpose is to create an object.

    when the constructor is called, it initializes the data members of the object and establishes the invariant of the class.

    Some important concepts:

    Data members: The data members are the data encapsulated within the object (e. g. int hour for the variable 'hour' in an object called 'date')

    Invariant of the class: The class invariant is the invariant used to constrain the object (e. g. values between 0 and 24 for the variable 'hour')
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “The main purpose of a constructor is to initialize the data members at the moment that an object is created. true or false? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers