Loading

Quipoin Menu

Learn • Practice • Grow

spring / Spring Bean Scopes
mcq
Direction: Choose the correct option

Q1.

What is the default scope of a Spring bean?
A. prototype
B. singleton
C. request
D. session
Direction: Choose the correct option

Q2.

Which scope creates a new bean instance for each request?
A. singleton
B. prototype
C. request
D. session
Direction: Choose the correct option

Q3.

Which scope is available only in web-aware Spring applications?
A. request
B. session
C. application
D. All of the above
Direction: Choose the correct option

Q4.

What is the request scope?
A. A single bean instance per HTTP request
B. A single bean instance per HTTP session
C. A single bean instance per ServletContext
D. A new instance for each method call
Direction: Choose the correct option

Q5.

Which annotation is used to specify bean scope?
A. @Scope
B. @ScopeType
C. @BeanScope
D. @ScopeDefinition
Direction: Choose the correct option

Q6.

What is the behavior of a singleton bean in Spring?
A. One instance per Spring container
B. One instance per JVM
C. One instance per thread
D. One instance per request
Direction: Choose the correct option

Q7.

What is a potential issue with injecting a prototype-scoped bean into a singleton bean?
A. The prototype bean becomes effectively singleton
B. It causes a circular dependency
C. It throws an exception
D. The prototype bean is recreated each time
Direction: Choose the correct option

Q8.

How can you overcome the prototype-in-singleton issue?
A. Use method injection
B. Use @Lookup annotation
C. Use ApplicationContextAware to get new instance
D. All of the above
Direction: Choose the correct option

Q9.

Which scope is similar to singleton but for the entire ServletContext?
A. application
B. globalSession
C. session
D. request
Direction: Choose the correct option

Q10.

What is the websocket scope used for?
A. Beans scoped to a WebSocket session
B. Beans scoped to an HTTP session
C. Beans scoped to a request
D. Beans scoped globally