Explore topic-wise MCQs in Spring.

This section includes 14 Mcqs, each offering curated multiple-choice questions to sharpen your Spring knowledge and support exam preparation. Choose a topic below to get started.

1.

RowMapper implementation which can automatically map a row to a new instance of the specified class.a) BeanPropertyRowMapperb) BeanPropertyRowc) All of the mentionedd) None of the mentionedAnswer: aExplanation: Note that the specified class must be a top-level class and must have a default or no-argument constructor. It first instantiates this class and then maps each column value to a property by matching their names.12. Method which provides list of maps.a) queryForList()b) updatec) query()d) all of the mentionedAnswer: aExplanation: Without the help of RowMapper, you can still call the queryForList() method and pass in a SQL statement. The returned result will be a list of maps. Each map stores a row of the result set with the column names as the keys.13. Spring JDBC framework offers a convenient class, to simplify your DAO implementation.a) org.springframework.jdbc.core.supportb) org.springframework.jdbc.core.support.JdbcDaoSupportc) all of the mentionedd) none of the mentionedAnswer: bExplanation: Spring JDBC framework offers a convenient class, org.springframework.jdbc.core.support.JdbcDaoSupport, to simplify your DAO implementation. This class declares a jdbcTemplate property, which can be injected from the IoC container or created automatically from a data source. 14. The org.springframework.jdbc.core.support.JdbcDaoSupport class has a setDataSource() method and a setJdbcTemplate() method.a) Trueb) FalseAnswer: aExplanation: Your DAO class can extend this class to have these methods inherited. 15. Method to retrieve the JDBC template.

A. BeanPropertyRowMapperb) BeanPropertyRowc) All of the mentionedd) None of the mentionedAnswer: aExplanation: Note that the specified class must be a top-level class and must have a default or no-argument constructor. It first instantiates this class and then maps each column value to a property by matching their names.12. Method which provides list of maps.a) queryForList()b) updatec) query()d) all of the mentionedAnswer: aExplanation: Without the help of RowMapper, you can still call the queryForList() method and pass in a SQL statement. The returned result will be a list of maps. Each map stores a row of the result set with the column names as the keys.13. Spring JDBC framework offers a convenient class, to simplify your DAO implementation.a) org.springframework.jdbc.core.supportb) org.springframework.jdbc.core.support.JdbcDaoSupportc) all of the mentionedd) none of the mentionedAnswer: bExplanation: Spring JDBC framework offers a convenient class, org.springframework.jdbc.core.support.JdbcDaoSupport, to simplify your DAO implementation. This class declares a jdbcTemplate property, which can be injected from the IoC container or created automatically from a data source. 14. The org.springframework.jdbc.core.support.JdbcDaoSupport class has a setDataSource() method and a setJdbcTemplate() method.a) Trueb) FalseAnswer: aExplanation: Your DAO class can extend this class to have these methods inherited. 15. Method to retrieve the JDBC template.a) setJdbcTemplate()
B. BeanPropertyRowc) All of the mentionedd) None of the mentionedAnswer: aExplanation: Note that the specified class must be a top-level class and must have a default or no-argument constructor. It first instantiates this class and then maps each column value to a property by matching their names.12. Method which provides list of maps.a) queryForList()b) updatec) query()d) all of the mentionedAnswer: aExplanation: Without the help of RowMapper, you can still call the queryForList() method and pass in a SQL statement. The returned result will be a list of maps. Each map stores a row of the result set with the column names as the keys.13. Spring JDBC framework offers a convenient class, to simplify your DAO implementation.a) org.springframework.jdbc.core.supportb) org.springframework.jdbc.core.support.JdbcDaoSupportc) all of the mentionedd) none of the mentionedAnswer: bExplanation: Spring JDBC framework offers a convenient class, org.springframework.jdbc.core.support.JdbcDaoSupport, to simplify your DAO implementation. This class declares a jdbcTemplate property, which can be injected from the IoC container or created automatically from a data source. 14. The org.springframework.jdbc.core.support.JdbcDaoSupport class has a setDataSource() method and a setJdbcTemplate() method.a) Trueb) FalseAnswer: aExplanation: Your DAO class can extend this class to have these methods inherited. 15. Method to retrieve the JDBC template.a) setJdbcTemplate()b) getTemplate()
C. All of the mentionedd) None of the mentionedAnswer: aExplanation: Note that the specified class must be a top-level class and must have a default or no-argument constructor. It first instantiates this class and then maps each column value to a property by matching their names.12. Method which provides list of maps.a) queryForList()b) updatec) query()d) all of the mentionedAnswer: aExplanation: Without the help of RowMapper, you can still call the queryForList() method and pass in a SQL statement. The returned result will be a list of maps. Each map stores a row of the result set with the column names as the keys.13. Spring JDBC framework offers a convenient class, to simplify your DAO implementation.a) org.springframework.jdbc.core.supportb) org.springframework.jdbc.core.support.JdbcDaoSupportc) all of the mentionedd) none of the mentionedAnswer: bExplanation: Spring JDBC framework offers a convenient class, org.springframework.jdbc.core.support.JdbcDaoSupport, to simplify your DAO implementation. This class declares a jdbcTemplate property, which can be injected from the IoC container or created automatically from a data source. 14. The org.springframework.jdbc.core.support.JdbcDaoSupport class has a setDataSource() method and a setJdbcTemplate() method.a) Trueb) FalseAnswer: aExplanation: Your DAO class can extend this class to have these methods inherited. 15. Method to retrieve the JDBC template.a) setJdbcTemplate()b) getTemplate()c) getJdbc()
D. None of the mentionedAnswer: aExplanation: Note that the specified class must be a top-level class and must have a default or no-argument constructor. It first instantiates this class and then maps each column value to a property by matching their names.12. Method which provides list of maps.a) queryForList()b) updatec) query()d) all of the mentionedAnswer: aExplanation: Without the help of RowMapper, you can still call the queryForList() method and pass in a SQL statement. The returned result will be a list of maps. Each map stores a row of the result set with the column names as the keys.13. Spring JDBC framework offers a convenient class, to simplify your DAO implementation.a) org.springframework.jdbc.core.supportb) org.springframework.jdbc.core.support.JdbcDaoSupportc) all of the mentionedd) none of the mentionedAnswer: bExplanation: Spring JDBC framework offers a convenient class, org.springframework.jdbc.core.support.JdbcDaoSupport, to simplify your DAO implementation. This class declares a jdbcTemplate property, which can be injected from the IoC container or created automatically from a data source. 14. The org.springframework.jdbc.core.support.JdbcDaoSupport class has a setDataSource() method and a setJdbcTemplate() method.a) Trueb) FalseAnswer: aExplanation: Your DAO class can extend this class to have these methods inherited. 15. Method to retrieve the JDBC template.a) setJdbcTemplate()b) getTemplate()c) getJdbc()d) getJdbcTemplate()Answer: dExplanation: In your DAO methods, you can simply call the getJdbcTemplate() method to retrieve the JDBC template. You also have to delete the dataSource and jdbcTemplate properties, as well as their setter methods, from your DAO class, because they have already been inherited. Again, for simplicity’s sake, only the change to the insert() method is shown.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!Telegram | Youtube | LinkedIn | Instagram | Facebook | Twitter | PinterestYoutube | LinkedIn | Instagram | Facebook | Twitter | Pinterest« Prev - Spring Questions and Answers – Problems with Direct JDBC» Next - Spring Questions and Answers – Using the Simple JDBC Template and Handling Exceptions
Answer» B. BeanPropertyRowc) All of the mentionedd) None of the mentionedAnswer: aExplanation: Note that the specified class must be a top-level class and must have a default or no-argument constructor. It first instantiates this class and then maps each column value to a property by matching their names.12. Method which provides list of maps.a) queryForList()b) updatec) query()d) all of the mentionedAnswer: aExplanation: Without the help of RowMapper, you can still call the queryForList() method and pass in a SQL statement. The returned result will be a list of maps. Each map stores a row of the result set with the column names as the keys.13. Spring JDBC framework offers a convenient class, to simplify your DAO implementation.a) org.springframework.jdbc.core.supportb) org.springframework.jdbc.core.support.JdbcDaoSupportc) all of the mentionedd) none of the mentionedAnswer: bExplanation: Spring JDBC framework offers a convenient class, org.springframework.jdbc.core.support.JdbcDaoSupport, to simplify your DAO implementation. This class declares a jdbcTemplate property, which can be injected from the IoC container or created automatically from a data source. 14. The org.springframework.jdbc.core.support.JdbcDaoSupport class has a setDataSource() method and a setJdbcTemplate() method.a) Trueb) FalseAnswer: aExplanation: Your DAO class can extend this class to have these methods inherited. 15. Method to retrieve the JDBC template.a) setJdbcTemplate()b) getTemplate()
2.

Method of RowMapper interface in which, you have to construct the object that represents a row and return it as the method’s return value.

A. mapRow()
B. query()
C. update()
D. none of the mentioned
Answer» B. query()
3.

RowCallbackHandler purpose is to map a single row of the result set to a customized object.

A. True
B. False
Answer» C.
4.

The primary interface that allows you to process the current row of the result set.

A. PreparedStatementSetter
B. PreparedStatementCreator
C. RowCallbackHandler
D. All of the mentioned
Answer» D. All of the mentioned
5.

When implementing the PreparedStatementCreator interface, you will get the database connection as the createPreparedStatement() method’s argument.

A. True
B. False
Answer» B. False
6.

ROWCALLBACKHANDLER_PURPOSE_IS_TO_MAP_A_SINGLE_ROW_OF_THE_RESULT_SET_TO_A_CUSTOMIZED_OBJECT.?$

A. True
B. False
Answer» C.
7.

Method_of_RowMapper_interface_in_which,_you_have_to_construct_the_object_that_represents_a_row_and_return_it_as_the_method’s_return_value.$#

A. mapRow()
B. query()
C. update()
D. none of the mentioned
Answer» B. query()
8.

The primary interface that allows you to process the current row of the result set?

A. PreparedStatementSetter
B. PreparedStatementCreator
C. RowCallbackHandler
D. All of the mentioned
Answer» D. All of the mentioned
9.

The JdbcTemplate class offers template method for batch update operations.

A. batchUpdate()
B. update()
C. all of the mentioned
D. none of the mentioned
Answer» D. none of the mentioned
10.

PreparedStatementSetter, as its name indicates, create a PreparedStatement object on this connection the parameter as well as binding task of the overall update process.

A. True
B. False
Answer» C.
11.

It is better to implement the PreparedStatementCreator interface and other callback interfaces as inner classes if they are used within one method only.

A. True
B. False
Answer» B. False
12.

When implementing the PreparedStatementCreator interface, you will get the database connection as the createPreparedStatement() method’s argument.$

A. True
B. False
Answer» B. False
13.

You implement this interface to override the statement creation task.

A. PreparedStatement
B. PreparedStatementCreator
C. PreparedCreator
D. None of the mentioned
Answer» C. PreparedCreator
14.

Class which declares a number of overloaded update() template methods to control the overall update process.

A. org.springframework.jdbc.core.JdbcTemplate
B. org.springframework.jdbc.core.*
C. org.springframework.jdbc.*
D. none of the mentioned
Answer» B. org.springframework.jdbc.core.*