Scala Quiz | 5 Min Challenge for Scala Programming

Free Scala course with real-time projects Start Now!!

This Scala Quiz will help you to boost your Scala knowledge and help to prepare for Scala interview.

DataFlair has published a series of Scala Quizzes from basic to advanced.

Before you start, please bookmark all quizzes and finish them before appearing for the next interview:

All The Best For Scala Quiz!!

We hope, you give all correct answers to this Scala Quiz. Have you enjoyed the Scala Quiz? Share your feedback with us!

Do not forget to share your score in the comments and challenge your friends to score more.

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

follow dataflair on YouTube

15 Responses

  1. jefferson says:

    Q.17. How do you turn the string “batmanstein” to the string “Man”?
    b. “batmanstein”.drop(3).take(3).capitalize
    d. “batmanstein”.drop(3).capitalize.take(3)
    b and d are correct

  2. Paresh says:

    Q.13. Select the statements that will successfully compile and run:
    a. val msg:String = "Testing" println(msg+" a horse ");
    b. var msg="Testing" println(msg+" a test")
    c. var msg="Testing" println("msg is :"+(msg=msg+" " +msg)
    d. All of the above

    What will be output, Can you give me explanation..!

    • DataFlair Team says:

      Hello Paresh,
      Nice Catch!
      Thanks for pointing out our typo mistake in this Scala Quiz. We make all the necessary changes. Now, all the statements will execute successfully.
      Regards,
      DataFlair

  3. Archana says:

    Q.19. What does the variable x hold in the following code:
    var x,y,z=(1,2,3)
    Correct answer should be 1

  4. Alejandro says:

    Which of the following statements are true about Lists and Arrays?
    Lists are immutable
    Arrays are mutable
    Once you have declared a List, you cannot add more elements later
    All of the above

    List can add more element with the method ::

  5. DataFlair Team says:

    Hello Alejandro,
    Thanks for playing the above Scala Quiz.
    Here is the answer of your query, Scala Lists are immutable whereas arrays are mutable in Scala. For complete information you can refer our Scala list tutorial.

  6. chcl says:

    > We do not need to pass these parameters to a method when calling it:

    Of course “Default parameters” is true! And it’s always true.

    “Implicit parameters”‌ is only true if and only if there are the right implicit values in scope!

    Please correct this mistake.

  7. chcl says:

    > UNIT is a data type in Scala. It pertains to no meaningful information.

    It’s called “Unit” not “UNIT”! Scala is case sensitive, remember? (Question 5)

  8. chcl says:

    > Consider the following statements about vals and vars. Select the ones that are true.

    > Reassigning to a val throws an error
    > Reassigning to a var doesn’t throw an error

    “Throws an error”‌ is very misleading. Throwing errors sounds like something that happens at runtime.

    What in fact happens is that compilation fails (with an error).

  9. chcl says:

    > A closure is:

    > A function whose return value depends on a variable declared outside it

    That’s simply false!

    The captured value doesn’t need to contribute to the return value. It can trigger side-effects without changing the closure return value. Or it can do simply nothing (dead code).

  10. chcl says:

    > What is a monad in Scala?

    > An object that wraps another

    That’s nonsense!

    Just don’t ask about monads if you don’t know what they are and how they’re implemented in Scala.

    Only after lifting a value into a monad it wraps the value. It’s not an wrapper as is.

  11. chcl says:

    > What is a type class in Scala?

    > A trait with at least one type variable

    No. That’s just a possible implementation of a type class. There are also other encodings!

    (This even contradicts the other wrong question about monads as monads are implemented with type classes. Boy…)

Leave a Reply

Your email address will not be published. Required fields are marked *