Scala Interview Questions

Practice for Scala interviews by solving TestDome questions. Our interview questions are used by more than 7,000 companies and 450,000 individual test takers.

Jobseekers: Certify Your Knowledge

Take a Certification Test

Companies: Use Our Tests for Screening

Buy a Pack Of Candidates

Need to practice your Scala programming skills for an upcoming job interview? Try solving these Scala interview questions that test knowledge of Scala programming concepts such as functions, closures, immutability, and other skills. We’ll provide feedback on your answers, and you can use a hint if you get stuck.

These Scala interview questions are examples of real tasks used by employers to screen job candidates such as Scala developers, back-end developers, full-stack developers, and others that require knowledge of the Scala programming language and its class library.

1. Merge Names

Scala Vector Public

Implement the uniqueNames function. When passed two vectors of names, it will return a vector containing the names that appear in either or both input vectors. The returned vector should have no duplicates.

For example, calling MergeNames.uniqueNames(Vector("Ava", "Emma", "Olivia"), Vector("Olivia", "Sophia", "Emma")) should return a vector containing Ava, Emma, Olivia, and Sophia in any order.

Solve Question

2. Player Inventory

Scala Bug Fixing Immutability Immutable Vector Public

The code for the PlayerInventory class is not working. When a user starts a new account, PlayerInventory is initialized with basic items. It should also be possible to add and drop items from the inventory, with duplicate items added and removed separately.

For example, if "lumber" was added to the inventory and "stone" was removed, getItems() should return a Vector containing "lumber", "magic potion", and "lumber", in any order.

Fix the bugs.

Solve Question

3. User Input

Scala Inheritance OOP Public

User interface contains two types of user input controls: TextInput, which accepts all characters and NumericInput, which accepts only digits.

Implement the class TextInput that contains:

  • Public method def add(c : Char) - concatenates the given character to the current value
  • Public method def getValue: String - returns the current value

Implement the class NumericInput that:

  • Inherits from TextInput
  • Overrides the add method so that each non-numeric character is ignored

For example, the following code should output "10":

val input: TextInput = new NumericInput()
Solve Question

4. Pipeline

Scala Closures Higher Order Function Public

As part of a data processing pipeline, complete the implementation of the makePipeline function:

  • The function should accept a variable number of functions, and it should return a new function that accepts one parameter arg.
  • The returned function should call the first function in the makePipeline with the parameter arg, and call the second function with the result of the first function.
  • The returned function should continue calling each function in the makePipeline in order, following the same pattern, and return the value from the last function.

For example, makePipeline((x: Int) => x * 3, (x: Int) => x + 1, (x: Int) => x / 2), and then calling the returned function with 3 should return 5.

Solve Question

If you feel ready, take one of our timed public Scala Interview Questions tests:

Scala Online Test (Easy / Hard)

Scala and SQL Online Test (Easy / Hard)


HTML/CSS, JavaScript, Scala, and SQL Online Test (Easy / Hard)

Not exactly what you are looking for? Go to our For Jobseekers section.
Dashboard Start Trial Sign In Home Tour Tests Questions Pricing For Jobseekers