Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Scala 3 Module 1

Start here: Scala 3.9 LTS on the JVM interview questions

Interview questions on “Start here: Scala 3.9 LTS on the JVM”: warm-ups, then what each harder question tests and how a good answer starts.

15 questions: 5 warm-ups and 10 with model answers · Levels: Fresher to staff

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    What is the difference between Scala Next and Scala LTS, and which would you use for a new library?

    Answered in the lesson What Scala 3 is and where it runs in 2026

  2. Fresher

    Why does Scala need a JDK, and which version does Scala 3.9 need?

    Answered in the lesson Install Scala 3.9, a JDK and an editor

  3. Fresher

    What does @main do in Scala 3, and how is it different from writing def main(args: Array[String]) yourself?

    Answered in the lesson First programs: scala run, scripts and the REPL

  4. Fresher to mid

    What does -Werror do, and why do teams turn it on in CI?

    Answered in the lesson Read Scala compiler errors and warnings

  5. Fresher

    What is the difference between == and eq in Scala, and how does it compare with Java and Python?

    Answered in the lesson Scala 3 for Java and Python developers

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    Your team maintains an internal library used by services on Scala 3.3.8 and on 3.9.0. A developer wants to publish the next release compiled with 3.10.0 to use a new language feature. What do you decide, and how do you roll it out?

    What it tests
    The one-way compatibility rule between Scala 3 minor versions, why libraries publish with an LTS version, and planning a version move for the users of a library.
    First step
    Write the rule down: Scala 3.b reads the output of 3.a only if b is at least a. A 3.10.0 build would shut out every 3.3 and 3.9 service, and even a 3.9.0 build shuts out the 3.3 ones. So list the library's users by Scala version before choosing anything.
    Follow-ups

    From the lesson What Scala 3 is and where it runs in 2026

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  2. Mid to staff

    A company writes Spark 4.2 jobs and back-end services in Scala and wants one shared module of domain code. Why can't both sides simply use Scala 3.9, and how would you structure the shared module?

    What it tests
    Knowing that Spark's Scala API fixes the jobs' Scala version, how Scala 2.13 and Scala 3 can use each other's libraries, and the cost of cross-building.
    First step
    Start from Spark's documentation: an application using the Scala API must use the Scala version Spark was compiled for, and Spark 4.2.0 runs on Scala 2.13. So the jobs compile with 2.13 and the services with 3.9, and the shared module must be readable from both.
    Follow-ups

    From the lesson What Scala 3 is and where it runs in 2026

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Fresher to senior

    A service moved from Scala 3.3.8 to 3.9.0. It still compiles and passes its tests in CI, but the container that runs it now fails at start-up with UnsupportedClassVersionError. Explain the error and how you would fix it, with the trade-offs.

    What it tests
    Class-file versions and the JDK minimum of Scala 3.8 and later, telling the build JDK from the runtime JDK, and choosing between moving the runtime and staying on 3.3 LTS.
    First step
    Read the two numbers in the message: the class-file version of the class and the highest one the JVM recognises. Scala 3.9 writes version 61, Java 17's, and a runtime that stops at 55 is JDK 11. So the build ran on a newer JDK than the container does.
    Follow-ups

    From the lesson Install Scala 3.9, a JDK and an editor

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Fresher to mid

    On a teammate's laptop, java -version prints 25, but the version report run with scala run prints Java 21, and the run still shows the JDK 25 warning lines. Explain what is happening, and how you would make every developer and CI run the same JDK.

    What it tests
    Knowing that the scala launcher follows PATH while the program follows JAVA_HOME, where the warnings come from, and pinning the JDK and the Scala version per project.
    First step
    Two JVMs are at work. The warnings come from the launcher, which runs on the first java on PATH, JDK 25, and the program runs on the JDK of JAVA_HOME, which must point at JDK 21 there. Check java -version, echo $JAVA_HOME and the report side by side.
    Follow-ups

    From the lesson Install Scala 3.9, a JDK and an editor

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  5. Mid to senior

    Your CI runs scala test and scala run in containers without internet access. After the image was rebuilt, the jobs fail with Error getting Bloop class path. Explain the cause and give two fixes, with their costs.

    What it tests
    Knowing that Scala CLI downloads the Bloop compile server, compilers and libraries on first use, what --server=false changes, and how to prepare a build image that works offline.
    First step
    Read the lines before the error: Scala CLI tried to download Bloop from Maven Central and every attempt failed. The old image must have had it in its cache. So ask what the rebuilt image lacks: Bloop, and perhaps the compiler and the libraries as well.
    Follow-ups

    From the lesson First programs: scala run, scripts and the REPL

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  6. Fresher to mid

    You are writing a small command-line tool in Scala 3 that other scripts call, for example split 17725 3. Design its entry point: an @main method with typed parameters, or your own argument handling? Cover error messages, exit status and testing.

    What it tests
    Knowing what the generated main does with bad, missing and extra arguments, keeping parsing apart from the logic, and choosing exit statuses that callers can rely on.
    First step
    Start from what the generated main does on Scala 3.9.0: it converts each argument, prints Illegal command line on a bad or missing one, ignores extra ones, and ends with status 0. A tool that scripts call needs a non-zero status on a mistake, so that behaviour alone is not enough.
    Follow-ups

    From the lesson First programs: scala run, scripts and the REPL

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  7. Mid to senior

    A payments service matches on an enum of payment methods. Someone added a new method, the build printed one warning, and production then threw MatchError for the new method. How do you fix it, and how do you stop this kind of bug for good?

    What it tests
    Exhaustivity checking on enums and sealed types, why a warning is not enough, -Werror in CI, and avoiding wildcard cases that hide new values.
    First step
    Read the warning the build printed: E029, match may not be exhaustive, it would fail on the new value. The compiler knew and the build did not stop. So fix every match it names first, then make such warnings fail the build.
    Follow-ups

    From the lesson Read Scala compiler errors and warnings

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  8. Fresher to mid

    A build fails with "No given instance of type Ordering[B] was found for parameter ord of method sorted" on a list of Order case classes. Walk through how you read the message, the ways to fix it, and which one you would choose.

    What it tests
    Reading a long E172 message from its first line, knowing what a given instance and a using parameter are, and choosing between sortBy, a natural order and named orderings.
    First step
    Read the first line first: sorted has a using parameter of type Ordering, and no given Ordering for Order exists. The rest of the message is the compiler's search. So decide how orders should be compared before writing any fix.
    Follow-ups

    From the lesson Read Scala compiler errors and warnings

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  9. Fresher to senior

    A Java library's lookup method returns null when a key is missing, and your Scala code calls it in 30 places. How do you make the Scala side null-safe, where do you convert, and what about values that arrive as Optional or as Java collections?

    What it tests
    Handling nulls once at the boundary with Option, converting Optional and Java collections with the scala.jdk converters, and knowing what the compiler can and cannot check.
    First step
    Find the boundary, the one place where the Java value enters your code. Wrap the call there in a small Scala method that returns an Option, built with Option(javaCall(key)), and let the 30 call sites use that method instead of the Java one.
    Follow-ups

    From the lesson Scala 3 for Java and Python developers

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  10. Mid to senior

    You port a Java service method, public Optional<User> findUser(String id) throws IOException, to Scala. Both Java and Scala code will call it. How do you design its signature for Scala callers, and what do Java callers get?

    What it tests
    Option and Optional at an API boundary, @throws for Java callers, and choosing between exceptions and an Either in a Scala API.
    First step
    Separate the two audiences. Scala callers want Option[User] and get nothing from a throws clause, because Scala does not check exceptions; Java callers want Optional<User> and a declared IOException. One method rarely serves both well, so design for Scala and add a thin Java-facing method.
    Follow-ups

    From the lesson Scala 3 for Java and Python developers

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All Scala 3 interview questions · The Scala 3 track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.