You are currently viewing scala linkedin assessment answers
scala linkedin assessment answers_theanswershome

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

4. From where do all classes in Scala inherit?

  • AnyRef
  • AnyClass
  • AnyColl
  • AnyVal

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

7. How many instances of a singleton can exist in the JVM at once?

  • none
  • 1
  • up to 32
  • 2

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

11. What does this code return?

  • “”
  • None
  • Null
  • Nil

12. What do you call a function defined in a block?

  • method
  • private function
  • block function
  • local function

13. Which operator should you use to take the intersection of two sets?

  • ||
  • &
  • &&
  • %

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)

Leave a Reply