Govt. Exams
Entrance Exams
The <bean> element is the standard XML element used in applicationContext.xml to define Spring beans.
@Autowired performs type-based dependency injection. Spring looks for a bean of the required type and injects it automatically.
Valid scopes are singleton, prototype, request, session, application, and websocket. 'eternal' is not a valid scope.
DI reduces coupling by injecting dependencies rather than creating them internally, making code more testable and maintainable.
@Component is a generic stereotype annotation for any Spring-managed component. @Bean is used on methods, while @Service and @Controller are specialized versions of @Component.
List numbers = Arrays.asList(1, 2, 3, 4, 5);
numbers.stream().filter(n -> n % 2 == 0).forEach(System.out::println);
The filter operation with lambda expression (n -> n % 2 == 0) filters even numbers only. So 2 and 4 are printed, each on a new line due to println.
BiPredicate<T, U> is a functional interface that takes two parameters and returns a boolean. This matches the requirement of taking two integers and returning a boolean value.
The lambda expression x -> x * 2 multiplies the input by 2. When applied to 5, it returns 10.
When a lambda has no parameters, empty parentheses () are required before the arrow. Options A and D are syntactically incorrect.
The arrow (->) in lambda expressions separates the parameter list on the left from the method body on the right. It's a syntax element specific to lambda expressions.