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 function defined for only part of its input domain
Explanation:
PartialFunction includes logic for testing whether an input is defined.
It is commonly used with pattern-based collection operations.
Choose an option to check your answer.
Correct Answer: D. Fixing some arguments of a function to create another function
Explanation:
A partially applied function retains provided arguments.
It can be reused where the remaining parameters vary.
Choose an option to check your answer.
Correct Answer: C. Transforming a function with multiple parameters into multiple parameter lists
Explanation:
Curried functions can support partial application and clearer APIs.
Each parameter list is supplied in sequence.
Choose an option to check your answer.
Correct Answer: B. A compile-time check that a method is tail recursive
Explanation:
Compilation fails if the recursive call cannot be optimized as tail recursion.
The annotation documents and enforces the intended structure.
Choose an option to check your answer.
Correct Answer: A. Recursion in which the recursive call is the final operation
Explanation:
Tail-recursive calls can be optimized into iteration by the compiler.
This avoids growing the call stack for each recursive step.
Choose an option to check your answer.
Correct Answer: D. The object may be serialized and sent to every executor task
Explanation:
Unnecessary closure capture increases network and memory overhead.
Extracting only required fields produces smaller serialized functions.
Choose an option to check your answer.
Correct Answer: C. A function that captures variables from its surrounding scope
Explanation:
The function carries references to external values it uses.
Spark must serialize captured values when sending closures to executors.
Choose an option to check your answer.
Correct Answer: B. Evaluates and stores its expression only when first accessed
Explanation:
Lazy initialization postpones work until the value is needed.
After the first evaluation, the result is cached.
Choose an option to check your answer.
Correct Answer: A. Immutable values can be shared without coordination for in-place changes
Explanation:
Concurrent tasks cannot overwrite an immutable value's state.
This reduces race conditions and makes reasoning about distributed code easier.
Choose an option to check your answer.
Correct Answer: D. A main method or an object extending App in supported versions
Explanation:
The JVM invokes a main entry point to start the program.
Build tools package the compiled classes and dependencies.
Choose an option to check your answer.
Correct Answer: C. An object with the same name as a class in the same source file
Explanation:
The class and companion object can access each other's private members.
The object often contains factory methods or constants.
Choose an option to check your answer.
Correct Answer: B. A singleton instance
Explanation:
An object is created once and can hold methods and values.
It is often used for application entry points or utility functions.