Scala Quiz
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “When do you need to explicitly state the return type in a function definition?”

Scala MCQs For LinkedIn Skill Assessments.

Scala is a strong statically typed general-purpose programming language which supports both object-oriented programming and functional programming.

Scala Quiz
Time left 00:00
25 Questions

1. What data type would you use to store an immutable collection of objects that contain a fixed number of varying types?
2. Why would you make a field private?
3. What type of number is 1234.e5?
4. What value does this code return?
scala
x= List(1,2,4); x(1)?
5. Which statement returns a success or a failure indicator when you execute this code?
'val MyFuture = Future {runBackgroundFunction() }'
6. What defines methods and fields that can then be reused by mixing into classes?
7. What is the output of this function?
scala
def main () {
var a = 0
for (a<-1 until 5){println(a)}
8. When do you need to explicitly state the return type in a function definition?
9. 'Note:' singletons may have mutable state
21. You have written a Scala script. How would you access command-line arguments in the script?"
10. What does this code return? 'val x = 3; if (x > 2) x = 4 else x = x*2'
11. Scala bytecode can run on top of Java VM. What is the fundamental difference between Java object.clone() and Scala object.copy()?
12. What type of object does this code create?

val x = (1234, 'Active')
13. What is denotes the intersection between two sets?
14. What would you change in this code to make it execute in parallel?

val myNums = (1 to 500).toList
list.map(_ + 1)
15. What is called when a superclass has more than one subclass in Scala?
16. To denote a parameter that may be repeated, what should you place after type?
17. What is the data type of y after this code is executed?

val y = (math floor 3.1415 * 2)
18. What do you call objects with immutable state?
19. After defining a function in the interpreter, Scala returns the following. What does the '()' indicate?

myfnc: ()Unit
20. What can you use to make querying a database more efficient, by avoiding the need to parse the SQL string every time a query is executed from Scala?
21. For the for-yield construct, is the scope separate between for-body and yield-body?
22. Which is a subclass of all classes?
23. What do you call a function defined in a block?
24. What do you call a Scala method that is parametrized by type as well as by value?
25. Which statement about if-else-if-else statements is true?