Spring Security MCQs with answers Page - 4

Here, you will find a collection of MCQ questions on Spring Security. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Arogya • 3.19K Points
Extraordinary

Q. Which annotation enables method-level security in Spring Security?

  • (A) @EnableMethodSecurity
  • (B) @EnableJpaRepositories
  • (C) @EnableScheduling
  • (D) @EnableCaching

A

Arogya • 3.19K Points
Extraordinary

Q. Which class stores authentication information in a thread-local context?

  • (A) SecurityContextHolder
  • (B) ApplicationContext
  • (C) BeanFactory
  • (D) ServletContext

A

Arogya • 3.19K Points
Extraordinary

Q. Which filter extracts username and password from login requests?

  • (A) UsernamePasswordAuthenticationFilter
  • (B) CorsFilter
  • (C) CharacterEncodingFilter
  • (D) HiddenHttpMethodFilter

A

Arogya • 3.19K Points
Extraordinary

Q. Which interface defines user details like username, password, and roles?

  • (A) UserDetails
  • (B) Serializable
  • (C) Runnable
  • (D) Comparator

A

Arogya • 3.19K Points
Extraordinary

Q. Which method is used to encode passwords using BCrypt?

Code:
PasswordEncoder encoder = new BCryptPasswordEncoder();
String hash = encoder.encode("mypassword");
  • (A) encode()
  • (B) hash()
  • (C) encrypt()
  • (D) protect()

A

Arogya • 3.19K Points
Extraordinary

Q. Which Spring Security feature allows cross-domain API requests?

  • (A) CORS configuration
  • (B) CSRF disable
  • (C) Session fixation
  • (D) Logout handler

A

Arogya • 3.19K Points
Extraordinary

Q. Which OAuth2 component represents the client application?

  • (A) Resource Server
  • (B) Authorization Server
  • (C) Client
  • (D) Principal

A

Arogya • 3.19K Points
Extraordinary

Q. Which attack is prevented by HTTP security headers like X-Frame-Options?

  • (A) Clickjacking
  • (B) SQL Injection
  • (C) DDoS
  • (D) Phishing

A

Arogya • 3.19K Points
Extraordinary

Q. Which configuration makes Spring Security not create HTTP sessions?

  • (A) sessionManagement() .sessionCreationPolicy( SessionCreationPolicy.STATELESS)
  • (B) sessionManagement() .maximumSessions(1)
  • (C) sessionManagement() .invalidSessionUrl("/login")
  • (D) sessionManagement() .migrateSession()

A

Arogya • 3.19K Points
Extraordinary

Q. What is the purpose of a remember-me feature?

  • (A) Delete cookies
  • (B) Keep users logged in across sessions
  • (C) Encrypt database
  • (D) Restart server

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ