Basics for Scalas
Basics covers the everyday building blocks of Scala 3: val and var, type inference, expressions that return values, methods, and classes, case classes, objects and traits. Traits are Scala's interfaces with optional implementation, and they, with classes, form the object-oriented half of the language.
Stage: Language · Part of the Scala roadmap · Last reviewed 19 November 2026
What to learn in Basics
- Declare immutable values with val and explain why var is rare
- Write methods with default and named parameters
- Define a case class and use its generated copy and equals
- Mix behaviour into a class using traits
- Create a singleton with object and a companion for factories
- Explain that if and match are expressions returning values
Basics interview questions
What is the difference between a class and a case class in Scala?
A case class is meant for immutable data. The compiler generates equals, hashCode, toString, copy and an apply factory, and it works with pattern matching. A regular class has none of that unless you write it yourself.
How does a trait differ from a Java interface?
A trait can hold concrete methods and fields, not just signatures, and a class can mix in several traits. Linearisation decides which implementation wins when they overlap. Java interfaces gained default methods but traits remain more flexible.
Where Basics fits in the Scala roadmap
Basics belongs to the Language stage (intermediate level), which takes about 28 hours. Scala 3 essentials.
Other units in this stage
Back to the full Scala roadmap