Author name: admin

How can you simulate an exception being thrown in Mockito?

How can you simulate an exception being thrown in Mockito? A) Using when().thenThrow() B) Using verify().thenThrow() C) Using mock().throw() D) Using assert().throw() Answer: A) Using when().thenThrow() Explanation: In Mockito, you can simulate an exception being thrown using the when().thenThrow() method. This is useful when you want to test how your code handles exceptions thrown by […]

How can you simulate an exception being thrown in Mockito? Read More »

Which method is used to verify that a method was called on a mock object in Mockito?

Which method is used to verify that a method was called on a mock object in Mockito? A) verify() B) assert() C) check() D) validate() Answer: A) verify() Explanation: In Mockito, the verify() method is used to check that a particular method was called on a mock object during the test. This is important for

Which method is used to verify that a method was called on a mock object in Mockito? Read More »

What is the Spring MVC framework used for?

What is the Spring MVC framework used for? A) To build web applications using the Model-View-Controller pattern B) To manage database connections C) To handle message queues D) To perform asynchronous processing Answer: A) To build web applications using the Model-View-Controller pattern Explanation: Spring MVC (Model-View-Controller) is a framework within the Spring Framework that is

What is the Spring MVC framework used for? Read More »

What is Spring AOP?

What is Spring AOP? A) A programming paradigm for modularizing cross-cutting concerns B) A tool for managing database transactions C) A library for building web applications D) A framework for dependency injection Answer: A) A programming paradigm for modularizing cross-cutting concerns Explanation: Spring AOP (Aspect-Oriented Programming) is a programming paradigm that helps modularize cross-cutting concerns,

What is Spring AOP? Read More »

What is the difference between @Component and @Bean in Spring?

What is the difference between @Component and @Bean in Spring? A) @Component is used for auto-detection, while @Bean is used for explicit bean declaration B) @Component is used for database access, while @Bean is used for services C) @Component is used in XML configuration, while @Bean is used in Java configuration D) @Component is used

What is the difference between @Component and @Bean in Spring? Read More »

Which container is responsible for managing the beans in Spring?

Which container is responsible for managing the beans in Spring? A) The Spring IoC container B) The Tomcat container C) The JPA container D) The Hibernate container Answer: A) The Spring IoC container Explanation: The Spring IoC container is responsible for managing the beans (objects) in a Spring application. It handles the creation, configuration, and

Which container is responsible for managing the beans in Spring? Read More »

What is the Spring Framework?

What is the Spring Framework? A) A comprehensive framework for Java application development B) A database management system C) A user interface library D) A logging framework Answer: A) A comprehensive framework for Java application development Explanation: The Spring Framework is a comprehensive, open-source framework for building enterprise-level Java applications. It provides a wide range

What is the Spring Framework? Read More »

Which of the following is a built-in password encoder provided by Spring Security?

Which of the following is a built-in password encoder provided by Spring Security? A) BCryptPasswordEncoder B) SHA256PasswordEncoder C) MD5PasswordEncoder D) RSAEncoder Answer: A) BCryptPasswordEncoder Explanation: Spring Security provides the BCryptPasswordEncoder as a built-in password encoder, which is widely used for securely hashing passwords. BCrypt is a strong, adaptive hashing algorithm designed to be computationally intensive,

Which of the following is a built-in password encoder provided by Spring Security? Read More »

What is the purpose of the @PreAuthorize annotation in Spring Security?

What is the purpose of the @PreAuthorize annotation in Spring Security? A) To check authorization before a method is invoked B) To encrypt user passwords C) To manage user sessions D) To log user activities Answer: A) To check authorization before a method is invoked Explanation: The @PreAuthorize annotation in Spring Security is used to

What is the purpose of the @PreAuthorize annotation in Spring Security? Read More »

Which annotation is used to secure a method in Spring Security?

Which annotation is used to secure a method in Spring Security? A) @Secured B) @Authenticated C) @Protected D) @Restricted Answer: A) @Secured Explanation: The @Secured annotation in Spring Security is used to secure individual methods by specifying which roles are allowed to invoke them. This annotation can be applied to methods in your service or

Which annotation is used to secure a method in Spring Security? Read More »

What is the purpose of the @EnableWebSecurity annotation?

What is the purpose of the @EnableWebSecurity annotation? A) To enable Spring Security’s web security support B) To configure database access C) To enable Spring Boot’s auto-configuration D) To create REST APIs Answer: A) To enable Spring Security’s web security support Explanation: The @EnableWebSecurity annotation is used to enable Spring Security’s web security support in

What is the purpose of the @EnableWebSecurity annotation? Read More »

Scroll to Top