Answer these 200+ Scala MCQs and see how sharp is your knowledge of Scala.
Scroll down and let's start!
A. "&"
B. "@"
C. "$"
D. "_"
A. private[examplepackage] def foo = {...}
B. package[examplepackage] def foo={...}
C. def foo={...} //default access
D. package def foo={...}//package private
E. [examplepackage]private def foo={...}
A. List(1,2,3) :: List(5)
B. List(1,2,3) + 5
C. List(1,2,3) :+ 5
D. List(1,2,3) ::= 5
E. List(1,2,3) :: 5
A. A default value, only used if the list is empty
B. A list, to which the results are appended.
C. The "accumulator," which is the initial value for `b`
D. The "accumulator," which is the initial value for `a`
A. AnyRef is the root Object in Scala
B. There is no such class
C. AnyRef is derived from AnyVal
D. All types except the value types descend from AnyRef
A. A type parameter which is fixed when the class is subtyped.
B. A type parameter which is allowed to vary up for super types.
C. A type parameter which is fixed for super types.
D. A type parameter which is allowed to vary down as the class is subtyped.
A. Yes, the JVM runtime supports tail-call optimization.
B. No
C. Partly at the compiler level. The compiler will try and unwind the recursive call into a loop.
D. Partly, because the stack is infinite in Scala.
A. Nothing
B. null
C. List()
D. None
A. Data-binding
B. Unifying types
C. Sealing classes
D. Currying
A. Functions
B. Parameters
C. Concepts
D. Constructs
A. By Inference
B. By Value
C. By Name
D. By Reference
A. Case classes as sealed and therefor cannot be extended
B. You can construct instances of these classes without using the new keyword
C. The toString method is automatically redefined
D. The equals method is automatically redefined
A. The "fold" operation
B. The current sum while iterating through the list
C. The next element in the list
D. The return value for the expression
A. When applying the function, you do not pass in arguments for all of the parameters defined by the function, but only for some of them, leaving the remaining ones blank
B. A function that support currying
C. A partially defined function.
D. An internal function type that is used by the scala.collection.immutable package.
A. List[Any]
B. List[Int]
C. List[AnyRef]
D. List[Boolean]
E. List[AnyVal]
A. Base-class
B. Super-script
C. Super-class
D. Function-class
A. There is no such thing as a sealed class.
B. A subclass of a sealed class can inherited anywhere only within the same package.
C. A sealed class may not be directly inherited, except if it is defined in the same source file.
D. A sealed class' instances cannot be modified.
A. ~
B. *
C. !
D. |
A. 22
B. 16
C. 2
D. 20
A. Subtype, ad-hoc and parametric polymorphism
B. Subtype and parametric
C. None of these
D. Parametric
E. Ad-hoc and parametric
A. Type safe
B. Type call
C. Type bound
D. Type function
A. automatically create a List[T] with x and y as members with T of 'Int' type
B. a Tuple with Arity 2
C. assign 100 to variable y
D. treat x and y as same references in the further code
E. produce a compile error
A. True
B. False
A. A simple class
B. A placeholder
C. A guard
D. A function
A. (List(1,2,3),List(4,5,6))
B. List(1,2,3,4,5,6)
C. 21
D. List(5,7,9)
E. List((1,4),(2,5),(3,6))
A. All string literals are an instance of scala.collection.immutable.StringOps
B. A subclass of java.lang.String is generated at runtime, adding the `length` method to its signature.
C. An implicit conversion converts the java.lang.String into a scala.collection.immutable.StringOps, which supports a length method.
D. All string literals can be processed by Scala String interpreter.
A. Scala does not support higher-order functions
B. Higher-order functions are parameterless functions that return themselves
C. Higher-order functions are functions that take other functions as parameters.
D. Higher-order functions are functions that return functions
A. An iterator is a collection type
B. Scala does not support Iterators
C. An Iterator is a stream of incoming items where advancing to the next item consumes the current item
D. An Iterator trait is mixed into all collection types
A. False
B. True
A. A guard
B. A tree
C. An array
D. A wild-card
A. A MatchError would be thrown.
B. Nothing would happen because "hi" is not of type "None"
C. The statement would return "hello!"
D. A NullPointerException would be thrown.
A. A dynamic language that can be used to program in object-oriented style efficiently
B. An advanced Object-Oriented Language much better than Java that runs on the JVM
C. An advanced Java language implemented by Martin Odersky
D. An object-functional language that supports functional programming constructs
E. A pure functional programming language
A. True
B. False
A. Yes, but only for traits.
B. No
C. Yes, but it is not idiomatic Scala and therefor discouraged.
D. Yes, all methods and functions must have at least one return statement.
A. True
B. False
A. Interface
B. Framework
C. Arguments
D. Platform
A. "void"
B. "bool"
C. "null"
D. "get"
A. A functional language
B. All of these choices describe Scala
C. An object oriented language
D. A language that runs on the VM
A. A mono object
B. A single argument
C. A singleton object
D. A static object
A. Objects
B. Methods
C. Booleans
D. Operations
A. "scalacom"
B. "cScala"
C. "scala.comp"
D. "scalac"
A. scala.AnyRef
B. You must always specify super-class
C. scala.importRef
D. scalac use.ref
A. True
B. False
A. The order of the pattern match is irrelevant
B. The case set must be exhaustive
C. Pattern matching does not work with case classes
D. Patterns do not work with structural types
A. public int %plus(int a)
B. You can't define a scala operator using Java source code.
C. public int #plus(int a)
D. private int $plus(int a)
E. public int $plus(int a)
A. A List is a finite immutable sequence
B. A List is optimal for last-in-first-out (LIFO), stack-like access patterns
C. List is a proxy for java.util.ArrayList
D. A List is covariant
A. False
B. True
A. String
B. Any
C. Unit
A. No
B. Yes
A. it will return the None because it matches on 'anything'
B. It will return "hi!" because a 'None' is a type of 'Option'
C. It won't compile
D. It will return 'anything'