Close
« Tutorial

Spring MVC - Custom Converter for POJOs MCQ

0/13
0 ✓
0 ✗

1. What is the main job of a custom Converter in Spring MVC data binding?

2. Which Spring feature can be used instead of PropertyEditor for String to type conversion?

3. How many ConversionService instances does Spring MVC use per container?

4. Which interface should a class implement to create a custom converter?

public class MyConverter implements ______ {
    ...
}

5. In Converter<S, T>, what do S and T mean?

6. Which method of the Converter interface performs the actual conversion?

public class MyConverter implements Converter {

    @Override
    public MyType ______(String source) {
        ...
    }
}

7. What is the usual source type when a converter handles a URI template variable?

8. What is one extra benefit of a custom converter compared to Spring's implicit mapping of request values to object properties?

9. Which interface defines callback methods to customize the Java-based configuration of Spring MVC?

10. Which annotation enables Spring MVC Java-based configuration?

@Configuration
______
public class AppConfig implements WebMvcConfigurer {
    ...
}

11. Which WebMvcConfigurer method is used to register custom converters and formatters?

@Override
public void ______(FormatterRegistry registry) {
    ...
}

12. Which method of FormatterRegistry is used to register a custom converter?

registry.______(new MyConverter());

13. Do converters added with addFormatters() replace the default converters?

14. When using @PathVariable without an explicit name, what must match for Spring to resolve the URI template variable to the method parameter?

15. What happens If a @PathVariable has no explicit name and no URI template variable matches the method parameter name?

16. When a converter creates the backing object for a handler method parameter, what does Spring do with that object before the handler method is called?

Join