What is the primary function of a 'constructor' in object-oriented programming?
B. To initialize the state of a new object when it is created.C. To allow objects of different classes to communicate.D. To define the methods that an object can perform.