How do we make a call to a private primary constructor in scala?
Answer / Kumar Gaurav
In Scala, you cannot directly call a private primary constructor. You should create an object companion that defines the application's entry point and use it instead.nExample:n```scalanclass MyClass private(val data: Int)nobject MyClass{n def apply(data: Int): MyClass = new MyClass(data)n}nMyClass(10)n```
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the equivalent construct of Scala’s Option in Java SE 8? What is the use of Option in Scala?
What is anonymous (lambda) function in scala?
What is implicit class in scala?
What does f method in scala string interpolation?
Popular clients who are using Play and Scala to develop their applications?
What is bitset in scala?
What is the use of auxiliary constructors in scala? explain the rules to follow in defining auxiliary constructors in scala?
What are the data types in scala?
What is a custom exception in scala?
What are the available Build Tools to develop Play and Scala based Applications?
Explain the main drawback of scala language?
What are the advantages of Play/Scala stack to develop web applications?