What is Primary Constructor? What is Secondary or Auxiliary Constructor in Scala?
Answer Posted / Ranjit Maurya
The primary constructor of a class is the one that takes parameters for initializing instance variables. In Scala, if no constructors are explicitly defined, a default primary constructor with no arguments will be automatically generated. A secondary or auxiliary constructor is a constructor that calls another constructor, usually the primary constructor, to initialize an object.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers