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 |
Give some examples of packages in scala?
What is a tuple in scala?
What is default access modifier in Scala?Does Scala have 'public' keyword?
What are the popular MVC frameworks for Scala Language to develop Web Applications?
List the default imports are available in scala language?
What are streams in scala?
Differentiate between null, nil, none and nothing?
What do you mean by scala map?
What is scala and why it is used?
In Scala, Pattern Matching follows which Design Pattern? In Java, ‘isinstanceof’ operator follows which Design Pattern?
What are the differences between Array and ArrayBuffer in Scala?
How is the scala code compiled?