Close
« Tutorial

Spring MVC - Custom Formatter MCQ

0/13
0 ✓
0 ✗

1. What is the main job of a Formatter in Spring MVC?

2. Which two interfaces does the Spring Formatter interface extend?

3. Which method of a Formatter turns an object into text?

4. Which method of a Formatter turns text into an object?

5. In Formatter<T>, what does the type T stand for?

6. Why do the print() and parse() methods receive a Locale parameter?

7. In which package is the Formatter interface found?

8. You want to register a custom formatter for the whole web application. Which method name completes the code?

@EnableWebMvc
@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Override
    public void ______(FormatterRegistry registry) {
        registry.addFormatter(new MyFormatter());
    }
}

9. Which method of FormatterRegistry is used to add a custom formatter?

10. What is the scope of a formatter that is registered with addFormatters()?

11. You want to customize a formatter only for a specific controller or request. Which approach can you use?

12. Which checked exception can the parse() method of a Formatter throw?

13. When does Spring MVC call the parse() method of a registered formatter?

14. When does Spring MVC use the print() method of a registered formatter?

15. How can one formatter class support more than one output style?

Join