What do you mean by trait in scala and when it is used?



What do you mean by trait in scala and when it is used?..

Answer / Ramgopal Singh

A Trait in Scala is a type that contains a certain number of methods, without providing their implementations. It allows for multiple inheritance (mixing) of behaviors. Traits are primarily used when a class needs to reuse code written in other classes. They can be mixed into classes and other traits using with keyword.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Scala Interview Questions

How to define Factory methods using object keyword in Scala? What is the use of defining Factory methods in object?

1 Answers  


What is apply method in Scala? What is unapply method in Scala? What is the difference between apply and unapply methods in Scala?

1 Answers  


What is a flatmap in scala?

1 Answers  


What do you mean by trait in scala and when it is used?

1 Answers  


What is the queue in the scala collection?

1 Answers  


What is the use of Auxiliary Constructors in Scala?Please explain the rules to follow in defining Auxiliary Constructors in Scala?

1 Answers  


Difference between Array and List in Scala?

1 Answers  


What is akka in scala? Explain

1 Answers  


What are the major advantages of Scala Language? Are there any drawbacks of Scala Language?

1 Answers  


What is method overloading in scala?

1 Answers  


Explain the difference between function and method in scala?

1 Answers  


What are the Scala variables?

1 Answers  


Categories