Scala LinkedIn Skill Assessment Answer

Here, We see Scala LinkedIn Skill Assessment Answer. This assessment test consists 15-20 MCQs to demonstrate your knowledge in your selected skills. MCQs comes from different topics – Control Flow, Data Structures, Data Types, Functional Programming, Object-Oriented Programming.

Scala LinkedIn Skill Assessment Answer

Scala LinkedIn Skill Assessment :-

Q1. Scala bytecode can run on top of Java VM. What is the fundamental difference between Java object.clone() and Scala object.copy()?

  1. One is a Java object, the other is a Scala object.
  2. clone() will copy class structures but not the data, while copy() will also copy data into new objects.
  3. There is no difference.
  4. copy() allows you to change values during the copying process; clone() does not.✔️

Q2. What value does this code return?

val m1 = Map("a"->1,"b"->2,"c"->3)
  1. a
  2. 2
  3. b
  4. 1✔️

Q3. What is one way to avoid low-level parallelization details?

  1. monads
  2. literal functions
  3. partially applied functions
  4. parallel collections✔️

Q4. What do you use in ScalaTest to see a detailed diagram of error messages when a test fails?

  1. ArgumentExceptions
  2. AssertionException
  3. DiagrammedAssertions✔️
  4. JUnit

Q5. What data type would you use to store an immutable collection of objects that contain a fixed number of varying types?

  1. Array
  2. ImmutableCollection
  3. List
  4. Tuple✔️

Q6. After defining a function in the interpreter, Scala returns the following. What does the () indicate?

myfnc: ()Unit
  1. The function has no side effects.
  2. The function takes no parameters.
  3. The function returns no value.✔️
  4. Returning unit types to the function is a closures.

Q7. What type of number is 1234.e5?

  1. hexadecimal
  2. short
  3. floating point✔️
  4. long

Q8. When you convert a map to a list using the toList method of the map, the result will be of which type?

  1. List[(String, String)]
  2. List[(Array, Array)]
  3. List[(Collection, Collection)]
  4. List✔️

Q9. What type of object does this code create?

val x = (1234, "Active")
  1. List
  2. Map
  3. Tuple✔️
  4. Array

Q10. Which is a subclass of all classes?

  1. AnyVal
  2. AnyRef
  3. Method
  4. Null✔️

Reference: Null in Scala Standard library

Q11. For the for-yield construct, is the scope separate between for-body and yield-body?

  1. Yes and no. It is different depending on the for construct and what it does.
  2. Yes, because the for section does not expose its scope.
  3. No, because for-yield shares the same scope, even though they are within separate curly braces.✔️
  4. Yes, because they are within different curly braces.
val a = Array(1, 2, 3, 4, 5)
for {
     e <- a if e > 2
} yield e

Q12. What is one way to implement pattern matching on methods?

  1. using regex
  2. using monads
  3. using string matching
  4. using case classes

Note: ambiguous question, it’s not clear what kind of pattern matching is meant here.

Q13. What is the value of z after executing this code?

val y = List('a','b')
val z = y::List('c')
  1. List(a,b,c)
  2. List(List(a, b), c)✔️
  3. List(c,a,b)
  4. List(c,List(a,b))

Q14. What term is used to specify a precondition?

  1. assert✔️
  2. require
  3. precondition
  4. mustHave

Q15. Which Scala type may throw an exception or a successfully computed value, and is commonly used to trap and propagate errors?

  1. scala.util.ExceptionHandling
  2. scala.Catch.Throw
  3. scala.exception.TryFinally
  4. scala.util.Try✔️

Reference: scala.util.Try

Q16. What is the data type of y after this code is executed?

val y = (math floor 3.1415 * 2)
  1. short
  2. double✔️
  3. int
  4. bigInt

Q17. When using pattern matching, which character matches on any object?

  1. %
  2. _✔️
  3. ^
  4. -

Reference: Pattern Matching

Q18. You have created an array using val. Can you change the value of any element of the array—and why or why not?

  1. Yes, the reference to the array is immutable, so the location that the array points to is immutable. The values in the array are mutable.✔️
  2. The 0th element is immutable and cannot be modified. All other elements can be modified.
  3. Yes, val does not make arrays immutable.
  4. No, val makes the array and values of the array immutable.

Q19. What is the output of this function?

def main () {
     var a = 0
     for (a<-1 until 5){println(a)}
  1. 1,2,3,4,5
  2. 0,1,2,3,4
  3. 1,2,3,4✔️
  4. 2,3,4,5

Q20. What do you call objects with immutable state?

  1. singletons
  2. stationary objects
  3. functional objects✔️
  4. fixed objects

Q21. You have written a Scala script. How would you access command-line arguments in the script?

  1. use array named args✔️
  2. use tuple named args
  3. use numbered variables with a _ prefix for example _ 1, _ 2, _ 3
  4. use numbered variables with a $ prefix – for example $1, $2, $3

Q22. What does this code return? val x = 3; if (x > 2) x = 4 else x = x*2

  1. 4
  2. an error✔️
  3. 6
  4. 3

Q23. Which statement returns a success or a failure indicator when you execute this code?

val MyFuture = Future {runBackgroundFunction() }

  1. myFuture.onComplete✔️
  2. myFuture(status)
  3. myFuture.Finished
  4. complete(myFuture)

Q24. To denote a parameter that may be repeated, what should you place after type?

  1. %
  2. &
  3. _
  4. -✔️

Q25. What is called when a superclass has more than one subclass in Scala?

  1. polyinheritance
  2. multilevel inheritance
  3. multimode inheritance
  4. hierarchical inheritance✔️

Q26. One way to improve code reliability is to use __ , which will evaluate a condition and return an error if the condition is violated.

  1. packages
  2. polymorphisms
  3. assertions✔️
  4. traits

Q27. Which statement about if-else-if-else statements is true?

  1. If the first else-if does not succeed, then no other else-ifs are tested.
  2. If an else-if does not succeed, then none of the remaining else-if statements or elses will be tested.
  3. All else-if statements are tested in all cases.
  4. If an else-if succeeds, then none of the remaining else-if statements or elses will tested.✔️

Q28. What do you call the process of changing the definition of an inherited method?

  1. recursive methods
  2. currying methods
  3. redefining methods
  4. overriding methods✔️

Q29. To denote a parameter that may be repeated, what should you place after the type?

  1. _
  2. *✔️
  3. %
  4. &

Reference: Repeated Parameters in Scala

Q30. What is the code below equivalent to?

myClass.foreach(println _)
  1. myClass.foreach(println ())
  2. myClass.foreach(print NIL)
  3. myClass.loop(println ())
  4. myClass.foreach(x => println(x))✔️

Q31. What is an advantage of an immutable object?

  1. Immutable objects use less memory than their mutable counterparts.
  2. Immutable objects do not require error handling.
  3. Immutable objects can be used in classes, mutable objects cannot.
  4. Immutable objects are threadsafe.✔️

Q32. You want to create an iteration loop that tests the condition at the end of the loop body. Which iteration would you use?

  1. do-while loop✔️
  2. while loop
  3. for loop
  4. do-until loop

Q33. 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?

  1. database driver
  2. connection
  3. prepared statement✔️
  4. SQL view

Reference: PreparedStatement from Java which is also used in Scala

Q34. Which is not a member of the collections hierarchy?

  1. Set
  2. Seq
  3. Hash✔️
  4. Map

Q35. Which term makes the contents of packages available without prefixing?

  1. use
  2. include
  3. import✔️
  4. assertion

Q36. If you wanted to find the remainder after division, what operator would you use?

  1. %✔️
  2. DIV
  3. //
  4. /

Q37. What are defined inside a class definition?

  1. method
  2. fields and methods✔️
  3. fields, methods, and packages
  4. fields

Q38. What defines methods and fields that can then be reused by mixing into classes?

  1. singleton
  2. assertion
  3. trait✔️
  4. monad

Q39. When do you need to explicitly state the return type in a function definition?

  1. when the function has no side effects
  2. when the function returns a Unit type
  3. when the function is recursive✔️
  4. when the function has side effects

Q40. Why would you make a field private?

  1. so only methods in the same file can access the field
  2. so only methods in the same package can access the field
  3. so only methods in the same class could access the field✔️
  4. so only methods defined in a Java class can access the field

Q41. What’s the difference between .equals and ==?

  1. They do the exact same thing
  2. == won’t work on objects
  3. == cannot be applied to String
  4. == is a wrapper of .equals() and checks for nulls✔️

Q42. What is denotes the intersection between two sets?

  1. ||
  2. &&
  3. &✔️
  4. %

Q43. What’s the best way to execute code in the background in a separate thread?

  1. AltFuture
  2. Future
  3. AltProcess
  4. AltThread

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

  1. private function
  2. block function
  3. local function
  4. method

Q45. What do you call a Scala method that is parametrized by type as well as by value?

  1. multimode method
  2. polymorphic method
  3. closure
  4. collection method

Q46. What type of exception is thrown when a precondition is violated?

  1. IllegalArgumentException✔️
  2. NumberFormatException
  3. NullPointerExcepetion
  4. MalformedParameterException

Q47. In scala what is precondition?

  1. a constraint on where a method may be called from
  2. a constraint on values passed to a methode constructor
  3. a class of predifined error messages✔️
  4. a class of Boolean operators

Q48. What would you change in this code to make it execute in parallel?

 val myNums = (1 to 500).toList + 1)
  1. **Change to **✔️
  2. Change toList to toListPar
  3. Change val to val.par
  4. Change toList to toParallelList

Q49. What is a free variable?

  1. a variable defined outside a function✔️
  2. a variable referenced in a function that is not assigned a value by that function
  3. a variable that has a global scope
  4. a variable defined in a class and available to all methods in that class

Q50. What is the difference between .equals() and == ?

  1. == is wrapper of .equals() and checks for Nulls✔️
  2. They do the exact same thing.
  3. == cannot be applied to String.
  4. == won’t work on objects

Q51. What’s the best way to execute code in the background in a separate thread?

  1. AltThread
  2. AltFuture
  3. AltProcess
  4. Future✔️

LinkedIn Scala Quiz Answers, LinkedIn Scala Assessment Answers, Scala LinkedIn Quiz Answers, Scala Assessment LinkedIn Answers, LinkedIn Skill Quiz Answers Scala, LinkedIn Scala Quiz, Scala LinkedIn Quiz, LinkedIn Quiz Answers Scala, LinkedIn Scala Assessment Quiz Answers, LinkedIn Skill Assessment Scala Answers, Scala LinkedIn Quiz, LinkedIn Scala Assessment Test Answers, LinkedIn Scala Test Answers, LinkedIn Scala Skill Assessment Answers, LinkedIn Skill Assessment Answers Scala, Scala LinkedIn Assessment Answers, LinkedIn Scala Assessment Answers, Scala LinkedIn Assessment Answers, Answers to LinkedIn Quizzes, LinkedIn Skill Assessment Answers GitHub, LinkedIn Assessment Test Answers, LinkedIn Skill Assessments Answers, Scala LinkedIn Skill Assessment Answer, Scala LinkedIn Skill Assessment Answer, Scala LinkedIn Skill Assessment Answer, LinkedIn assessment answers, LinkedIn skill assessment answers, LinkedIn assessments, LinkedIn skill assessment, LinkedIn assessment answers 2021, LinkedIn assessment answers GitHub, LinkedIn assessment quiz answers

No post found!

Leave a Comment

Your email address will not be published.