Spring Questions and Answers – Spring Batch infrastructure and Reading,Writing

«
»

This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “Spring Batch infrastructure and Reading, Writing”.

1. Spring Batch provides a lot of flexibility and guarantees to your application, but it cannot work in a vacuum. To do its work:-
a) Job
b) JobRepo
c) JobRepository
d) All of the mentioned
View Answer

Answer: c
Explanation: To do its work, the JobRepository requires a database. Additionally, there are several collaborators required for Spring Batch to do its work. This configuration is mostly boilerplate.
advertisement

2. There’s only one really useful implementation of the JobRepository interface, which stores information about the state of the batch processes in a database.
a) SimpleJobRepository
b) SimpleJob
c) SimpleRepo
d) All of the mentioned
View Answer

Answer: a
Explanation: Creation is done through a JobRepositoryFactoryBean. Another standard factory, MapJobRepositoryFactoryBean is useful mainly for testing because its state is not durable – it’s an in-memory implementation. Both factories create an instance of SimpleJobRepository.

3. To load the contents of a properties file (batch.properties) whose values you use to configure the data source.
a) PropertyPlaceholder
b) PropertyPlaceholderConfigurer
c) Property
d) PropertyConfigurer
View Answer

Answer: b
Explanation: You need to place values for your particular database in this file. This example uses Spring’s property schema (“p”) to abbreviate the tedious configuration.

4. MapJobRegistry instance. This is critical—it is the central store for information regarding a given Job.
a) True
b) False
View Answer

Answer: a
Explanation: It controls the “big picture” about all Jobs in the system. Everything else works with this instance.

5. SimpleJobLauncher, whose sole purpose is to give you a mechanism to launch batch jobs, where a “job” in this case is our batch solution.
a) True
b) False
View Answer

Answer: a
Explanation: The jobLauncher is used to specify the name of the batch solution to run as well as any parameters required.
advertisement

6. Spring Batch models solutions using XML schema.
a) True
b) False
View Answer

Answer: a
Explanation: This schema is new to Spring Batch 2.1.

7. However, it’s important to wear another hat, that of a DBA, when writing applications.
a) True
b) False
View Answer

Answer: a
Explanation: A common solution is to create a denormalized table whose contents can be coerced into valid data once inside the database, perhaps by a trigger on inserts.

8. Indeed, a step could be considered the smallest unit of work for a job. Input (what’s read) is passed to the Step and potentially processed; then output (what’s written) is created from the step.
a) Steplet
b) Tasklet
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: b
Explanation: This processing is spelled out using a Tasklet. You can provide your own Tasklet implementation or simply use some of the preconfigured configurations for different processing scenarios.

9. Attribute to configure how many items will be processed before the transaction is committed all the input is sent to the writer.
a) interval
b) commit
c) commit-interval
d) none of the mentioned
View Answer

Answer: c
Explanation: If there is a transaction manager in play, the transaction is also committed.
advertisement

10. Class which delegates the task of delimiting fields and records within a file to a LineMapper, which in turn delegates the task of identifying the fields within that record, to LineTokenizer.
a) org.springframework.batch.item.file.FlatFileItemReader
b) org.springframework.batch.item.file.FlatFile
c) org.springframework.batch.item.file.FlatFileItem
d) org.springframework.batch.item.file.FileItemReader
View Answer

Answer: a
Explanation: The FlatFileItemReader also declares a fieldSetMapper attribute that requires an implementation of FieldSetMapper.

11. The names and values for the named parameters are being created by the bean configured for the itemSqlParameterSourceProvider property, an instance of the interface
a) BeanPropertyItemSqlParameterSourceProvider
b) BeanPropertyItemSqlParameterSource
c) BeanPropertyItemSqlParameter
d) All of the mentioned
View Answer

Answer: a
Explanation: BeanPropertyItemSqlParameterSourceProvider, whose sole job it is to take JavaBean properties and make them available as named parameters corresponding to the property name on the JavaBean.

12. There’s support for writing JMS:-
a) JmsItemWriter
b) JpaItemWriter
c) JdbcBatchItemWriter
d) All of the mentioned
View Answer

Answer: d
Explanation: There’s support for writing JMS (JmsItemWriter), JPA (JpaItemWriter), JDBC (JdbcBatchItemWriter), Files (FlatFileItemWriter), iBatis (IbatisBatchItemWriter), Hibernate (HibernateItemWriter), and more.

13. The processor attribute on the chunk element expects a reference to a bean of the interface:-
a) org.springframework.batch.item.Item
b) org.springframework.batch.item
c) org.springframework.batch.item.ItemProcessor
d) none of the mentioned
View Answer

Answer: c
Explanation: The processor attribute on the chunk element expects a reference to a bean of the interface org.springframework.batch.item.ItemProcessor.
advertisement

14. Spring Batch provides a convenience class, CompositeItemProcessor, which forwards the output of the filter to the input of the successive filter.
a) True
b) False
View Answer

Answer: a
Explanation: In this way, you can write many, singly focused ItemProcessors and then reuse them and chain them as necessary.

15. If the preceding job was run on a batch with a 100 rows, each item was read and passed through the processor, and it found 10 items invalid (it returned null 10 times), the value for the filter_count column would be:-
a) 100
b) 1
c) 10
d) 1000
View Answer

Answer: c
Explanation: You could see that a 100 items were read from the read_count. The write_count column would reflect that 10 items didn’t make it and would show 90.

Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn