Practice Library
All MCQs
Browse exam-wise, subject-wise, and country-wise MCQs with explanations.
Choose an option to check your answer.
Correct Answer: A. A collection of unique elements
Explanation:
Sets support membership tests and set operations.
Duplicate insertions do not create repeated elements.
Choose an option to check your answer.
Correct Answer: D. A fixed-length mutable indexed collection
Explanation:
Array elements can be changed in place.
Its length is determined when the array is created.
Choose an option to check your answer.
Correct Answer: C. An immutable indexed sequence with efficient random access
Explanation:
Vector provides more balanced indexed access and updates than List.
It remains immutable.
Choose an option to check your answer.
Correct Answer: B. An immutable linked sequence
Explanation:
List is optimized for operations at the head and recursive processing.
Creating a changed list returns a new value.
Choose an option to check your answer.
Correct Answer: A. Partial results may be combined in different groupings
Explanation:
Distributed engines can aggregate partitions in varying tree shapes.
Associativity ensures the grouping does not change the answer.
Choose an option to check your answer.
Correct Answer: D. Combines elements using a binary operation
Explanation:
The operation repeatedly merges two elements into one result.
For parallel use, associative operations are especially important.
Choose an option to check your answer.
Correct Answer: C. Maps each element to a collection and flattens the results
Explanation:
flatMap is useful when one input can produce zero or many outputs.
Tokenizing lines into words is a common example.
Choose an option to check your answer.
Correct Answer: B. Keeps elements satisfying a Boolean predicate
Explanation:
The predicate is evaluated for each element.
Only elements for which it returns true remain.
Choose an option to check your answer.
Correct Answer: A. Applies a function to each element and returns the transformed collection
Explanation:
The output contains one transformed result for each input element.
The original immutable collection remains unchanged.
Choose an option to check your answer.
Correct Answer: D. A function that accepts or returns another function
Explanation:
Higher-order functions support reusable behavior and functional composition.
Examples include map, filter, and reduce.
Choose an option to check your answer.
Correct Answer: C. An anonymous function such as x => x * 2
Explanation:
Anonymous functions can be passed as values to higher-order methods.
Spark transformations frequently use them.
Choose an option to check your answer.
Correct Answer: B. The value produced by the selected branch
Explanation:
Scala's if is an expression rather than only a control statement.
Both branches can contribute to the inferred result type.