“This set of Java Spring Interview Questions and Answers for freshers focuses on “User Locales and Locale-Sensitive Text Messages”.
1. Interface implemented by locale resolver.
a) localeResolver
b) tiles
c) front controller
d) none of the mentioned
View Answer
Explanation: In a Spring MVC application, a user’s locale is identified by a locale resolver, which has to implement the LocaleResolver interface.
2. You can define a locale resolver by registering a bean of type LocaleResolver in the web application context.
a) True
b) False
View Answer
Explanation: You must set the bean name of the locale resolver to localeResolver for DispatcherServlet to auto-detect.
3. Default localeResolver used by Spring.
a) AcceptHeaderLocale
b) AcceptHeader
c) AcceptHeaderLocaleResolver
d) AcceptLocaleResolver
View Answer
Explanation: The default locale resolver used by Spring is AcceptHeaderLocaleResolver.
4. AcceptHeaderLocaleResolver esolves locales by inspecting the accept-language header of an HTTP request.
a) True
b) False
View Answer
Explanation: This header is set by a user’s web browser according to the locale setting of the underlying operating system.
5. Alternative way to resolve locales.
a) AcceptHeaderLocale
b) AcceptHeader
c) AcceptHeaderLocaleResolver
d) SessionLocaleResolver
View Answer
Explanation: Another option of resolving locales is by SessionLocaleResolver.
6. Property which indicates how many seconds this cookie should be persisted.
a) cookieMaxAge
b) cookieName
c) cookieAge
d) none of the mentioned
View Answer
Explanation: The cookieMaxAge property indicates how many seconds this cookie should be persisted.
7. Method used to change user’s locale.
a) set
b) setLocale
c) locale
d) set_locale
View Answer
Explanation: Changing a user’s locale by calling LocaleResolver.setLocale() explicitly.
8. Property of LocaleChangeInterceptor used to customize parameter name.
a) localeResolver.setLocale
b) paramName
c) locale.parm
d) none of the mentioned
View Answer
Explanation: Changing a user’s locale by calling LocaleResolver.setLocale() explicitly.
9. LocaleChangeInterceptor can only detect the parameter for the handler mappings that enable it.
a) True
b) False
View Answer
Explanation: So, if you have more than one handler mapping configured in your web application context, you have to register this interceptor to allow users to change their locales in any of the URLs.
10. Parameter which can change user’s locale by any URL.
a) locale
b) languageURL
c) language
d) none of the mentioned
View Answer
Explanation: Now a user’s locale can be changed by any URLs with the language parameter.
11. Interface used to resolve text messages.
a) Message
b) Message_Source
c) Language
d) MessageSource
View Answer
Explanation: Spring is able to resolve text messages for you by using a message source, which has to implement the MessageSource interface.
12. Tag used by view to resolve text messages.
a) spring:message
b) spring:language
c) spring:title
d) none of the mentioned
View Answer
Explanation: Then your JSP files can use the spring:message tag, defined in Spring tag library, to resolve a message given the code.
13. The ResourceBundleMessageSource implementation resolves messages for different locales.
a) True
b) False
View Answer
Explanation: The ResourceBundleMessageSource implementation resolves messages from different resource bundles for different locales.
14. cookieName is used by localeResolver to customize the cookie used.
a) True
b) False
View Answer
Explanation: The cookie used by this locale resolver can be customized by setting the cookieName and cookieMaxAge properties.
15. The cookieMaxAge value when browser is closed.
a) 0
b) 1
c) -1
d) true
View Answer
Explanation: The value -1 indicates that this cookie will be invalid after the browser is closed.
Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring for interviews, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in Spring
- Participate in Spring Certification Contest
- Become a Top Ranker in Spring
- Take Spring Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy Spring Books
- Apply for Programming Internship
- Buy Information Technology Books
- Apply for Spring Internship
- Practice Programming MCQs