What is the function of a constructor in Java?
Show answer
Correct answer B
A constructor is automatically called when an object is instantiated, setting initial values. Unlike regular methods, it has the same name as the class and does not have a return type.