Scala Quiz - 1

himanshu arora
Quiz by himanshu arora, updated more than 1 year ago
himanshu arora
Created by himanshu arora over 3 years ago
210
0

Description

The 1st scala quiz for Scala.IO

Resource summary

Question 1

Question
What is NOT necessarily a property of a monoid ?
Answer
  • Associativity
  • Identity
  • Functions map & flatMap
  • Closure

Question 2

Question
SBT can execute tasks in parallel ?
Answer
  • True
  • False

Question 3

Question
What is the LEAST true statement for an actor akka ?
Answer
  • Communicates using messages
  • Used for concurrency management
  • Asynchronous and non-blocking
  • Used for parallel programming

Question 4

Question
Future.successful(10) Future.successful(20) The above mentioned 2 futures run on two different threads ?
Answer
  • True
  • False

Question 5

Question
val mySeq = Seq("Hello world", "How are you doing", "See you soon") val mySeqMap = mySeq.map(_.split(" ")).filter(_.length > 3) val mySeqFlatMap = mySeq.flatMap(_.split(" ")).filter(_.length > 3) What are the possible values of mySeqMap and mySeqFlatMap respectively ?
Answer
  • mySeqMap = List(How, are, you, doing) mySeqFlatMap = List(Hello, world, doing, soon)
  • mySeqMap = List(List(How, are, you, doing)) mySeqFlatMap = List(Hello, world, doing, soon)
  • mySeqMap = List(Hello, world, doing, soon) mySeqFlatMap = List(List(How, are, you, doing))
  • mySeqMap = List(List(How, are, you, doing)) mySeqFlatMap = List(Hello, world, doing, are, you, soon)

Question 6

Question
case class People(name: String, age: Int) val people1 = People("Jon", 30) val people2 = People("Jon", 30) people1 == people2 ?
Answer
  • True
  • False

Question 7

Question
A FUNCTOR must have ?
Answer
  • map function
  • flatMap function
  • map and flatMap both
  • none of the above

Question 8

Question
trait F[+A] { def {...} } What does +A represent ?
Answer
  • Upper bound
  • Contravariant type parameter
  • Covariant type parameter
  • Lower bound

Question 9

Question
What's a closure ?
Answer
  • A function whose return value depends upon a variable declared outside of that function
  • A function that takes another function as an argument
  • A function that returns a function as argument
  • A function that returns a future

Question 10

Question
Which of the following statements about a scala Either are true (multiple responses possible) ?
Answer
  • It has two subtypes Left and Right
  • Left represents success case and Right represents error case
  • Left represents error case and Right represents success case
  • Both Left and Right are case classes
Show full summary Hide full summary

Similar

CCNA Security 210-260 IINS - Exam 3
Mike M
Application of technology in learning
Jeff Wall
Ch1 - The nature of IT Projects
mauricio5509
The Internet
Gee_0599
Innovative Uses of Technology
John Marttila
CCNA Answers – CCNA Exam
Abdul Demir
SQL Quiz
R M
Professional, Legal, and Ethical Issues in Information Security
mfundo.falteni
Flash Cards Networks
JJ Pro Wrestler
USER INTERFACES
Calum_Weeks
System Analysis
R A