All fields

“Streams & Lambdas” in Information Technology

17 questions across 2 technologies.

Information Technology

17 questions in 2 technologies

#QuestionTechnologyTopicLevel
1What is the Strategy pattern, and how do Java 8's functional interfaces and lambdas make implementing it significantly more concise than the traditional interface-plus-implementation-classes approach? Java › Design Patterns in JavaJavaDesign Patterns in JavaIntermediate
2What is the Java Collections Framework, and what are the core interfaces (List, Set, Map, Queue) at its foundation? Java › Collections FrameworkJavaCollections FrameworkBeginner
3What is the difference between the Iterable and Iterator interfaces, and how does the enhanced for-each loop rely on them? Java › Collections FrameworkJavaCollections FrameworkBeginner
4How do you retrieve all constants of an enum type, and how would you iterate over them? Java › EnumsJavaEnumsBeginner
5What is a functional interface, and what are the four core functional interfaces in java.util.function (Function, Predicate, Consumer, Supplier)? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesBeginner
6What are the four kinds of method references in Java (static, instance-bound, instance-unbound, and constructor), and how does the compiler determine which form applies? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
7How do the default methods andThen() and compose() on Function work, and what's the difference between them for chaining transformations? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
8What is the difference between UnaryOperator<T> and Function<T,T>, and why does UnaryOperator exist as a separate, more specific interface? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
9How do the primitive-specialized functional interfaces (IntFunction, ToIntFunction, IntPredicate, IntUnaryOperator, etc.) avoid the performance cost of autoboxing, and when should you prefer them over the generic equivalents? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
10How does the Predicate interface's default methods and(), or(), and negate() enable composing complex boolean conditions from simpler ones? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
11What is the difference between a Consumer<T> and a BiConsumer<T,U>, and how would you use BiConsumer for operations needing two inputs but no return value, such as Map.forEach()? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
12How do you write a generic method (as opposed to a generic class), and how does the compiler infer the type parameter from the arguments passed at a call site? Java › GenericsJavaGenericsIntermediate
13What is LINQ, and how does it simplify querying collections compared to writing manual loops? C# › LINQC#LINQIntermediate
14How would you implement a custom Comparator with multiple sort criteria (e.g., sort by last name, then by first name as a tiebreaker) using the Comparator.comparing() and thenComparing() fluent API? Java › Collections FrameworkJavaCollections FrameworkAdvanced
15How would you implement a custom compareTo()-based ordering for an enum that differs from its natural declaration-order ordering, given Comparable's default implementation uses ordinal()? Java › EnumsJavaEnumsAdvanced
16How would you use BiFunction combined with Stream's reduce() to implement a custom aggregation, and how does this relate to the more general concept of a fold operation in functional programming? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesAdvanced
17How would you use a local class defined within a method to implement a fairly complex, stateful callback that needs multiple methods and constructor parameters, where a lambda expression genuinely wouldn't suffice? Java › Inner Classes & Anonymous ClassesJavaInner Classes & Anonymous ClassesAdvanced