InterviewSolution
Saved Bookmarks
| 1. |
What are different types of constructors used in Scala? |
|
Answer» The constructors are responsible for initializing the state of the object. In the same way as methods, constructors also consist of statements/instructions that are executed when an object is created. Constructors are used in Scala to create INSTANCES of CLASSES. Scala has two types of constructors:
Syntax: class class_name(Parameter_list) { // Statements... }
Syntax: def this(......) |
|