juniorScala

What are traits in Scala?

Updated May 24, 2026

Short answer

Traits are interfaces with optional implementations.

Deep explanation

They allow code reuse and multiple inheritance of behavior, unlike Java classes.

Real-world example

Used for logging and service composition.

Common mistakes

  • Overusing traits for everything.

Follow-up questions

  • Difference between trait and abstract class?
  • Can traits have state?

More Scala interview questions

View all →