scala linkedin assessment answers
1. What are the subclasses of Any?
- AnyVal and AnyRef
- AnyColl and AnySet
- AnyRef and AnyColl
- AnyVal, AnyRef, and AnyColl
2. Which statement accesses the third element of an array named foo?
- foo(2)
- f00 [3]
- foo[2]
- foo (3)
3. What clause should you use with try to force the execution of code even in the case of an exception?
- force
- catch
- finally
- throw
5. Which expression is one way to iterate over a collection and generate a collection of each iteration's result?
- for-collect
- for-collect until
- collectuntil
- for-yield
6. What is a free variable?
- a variable that has a global scope
- a variable defined outside a function
- a variable defined in a class and available to all methods in that class
- a variable referenced in a function that is not assigned a value by that function
8. What is it called when a superclass has more than one subclass in Scala?
- multimode inheritance
- hierarchical inheritance
- multilevel inheritance
- polyinheritance
9. What data type would you use to store an immutable collection of objects when you don't know how many members will be in the collection?
- Array
- List
- Object
- Tuple
10. In Scala, what is a precondition?
- a constraint on where a method may be called from
- a constraint on values passed to a method or constructor
- a class of predefined error messages
- a class of Boolean operators
12. What do you call a function defined in a block?
- method
- private function
- block function
- local function
14. After defining a function in the interpreter, Scala returns the following What does the () indicate?
myfnc: ()Unit
- The function returns no value.
- The function takes no parameters.
- Returning unit types to the function is a closures.
- The function has no side effects.
15. What is equivalent to myCollection.foreach(x=>println(x))?
- myCollection.foreach(println _)
- mycollection.foreach(println ( ) )
- foreach.apply (println( ), myCollection)
- foreach(myCollection,println)