T or F. val x: Int = 1 is equivalent to val x = 1
True
Does the ++ operator exists in scala?
No
What type is y in the expression val y = if x > 0 then 1?
Unit
What is the type of an assignment statement in Scala?
Unit
T or F. Break & continue don’t exist in Scala.
True
T or F. daysToHours(hoursInDay = 153, days = 3) is valid syntax but ordering of parameters must be correct.
False, is valid even if ordering incorrect.
Distinguish between def, val and lazy val.
Def = evaluate every time function used.
val = evaluate immediately on definition
lazy val = evaluated only first time it is used (not defined), possibly never.
Give a basic run down of collection class hierarchy.
Traversable -> Iterable -> {Set, Seq, Map}
Difference between array and arrayBuffers.
arrayBuffers dont need to know what size before runtime.
What are Vectors?
They are indexed like arrays but are immutable.
How are multidimensional arrays implemented in Scala.
Array[Array[Int]]
How would you create Map[String, Int]?
val scores = Map(“Mike” -> 3, “Lucy” -> 5, “Alex” -> 7)
Does var/val, mutability/immutability affect object or reference.
Var/val = reference
Mutability/Immutability = object
What is a List?
An immutable sequence of objects of the same type. Linked list.
Difference between vector and list.
Vector implemented as array so fast access. Bad for pattern matching.
List implemented as linked list so slow access. Great for pattern matching.