250+ TOP MCQs on Problems with Direct JDBC and Answers

Java Spring Multiple Choice Questions & Answers (MCQs) on “Problems with Direct JDBC”.

1. Spring supports most of the popular ORM (or data mapper) frameworks.
a) Hibernate
b) JDO
c) JPA
b) All of the mentioned
Answer: d
Clarification: Spring supports most of the popular ORM (or data mapper) frameworks, including Hibernate, JDO, iBATIS, and the Java Persistence API (JPA).

2. ORM which isn’t supported by Spring:-
a) Hibernate
b) JDO
c) TopLink
b) All of the mentioned
Answer: d
Clarification: Classic TopLink isn’t supported starting from Spring 3.0 (the JPA implementation still supported, of course).

3. An ORM framework persists your objects according to the mapping metadata you provide.
a) True
b) False
Answer: a
Clarification: XML- or annotation-based, such as the mappings between classes and tables, properties and columns, and so on.

4. Database Engine which uses low memory consumption and easy configuration.
a) SQL
b) MySQL
c) Apache Derby
d) None of the mentioned
Answer: c
Clarification: Derby is an open source relational database engine provided under the Apache License and implemented in pure Java.

5. Mode which Derby prefers to run in:-
a) embedded
b) client/server
c) all of the mentioned
d) none of the mentioned
Answer: c
Clarification: Derby can run in either the embedded mode or the client/server mode.

6. For testing purposes, the client/server mode is more appropriate.
a) True
b) False
Answer: a
Clarification: It allows you to inspect and edit data with any visual database tools that support JDBC—for example, the Eclipse Data Tools Platform (DTP).

7. To start the Derby server in the client/server mode.
a) startNetworkServer java file
b) startNetworkServer script
c) startNetwork script
d) all of the mentioned
Answer: b
Clarification: To start the Derby server in the client/server mode, just execute the startNetworkServer script for your platform (located in the bin directory of the Derby installation).

8. JDBC Properties for Connecting to the Application Database.
a) Driver Class
b) URL
c) Username
d) All of the mentioned
Answer: d
Clarification: JDBC Properties for Connecting to the Application Database
Property Value
Driver class org.apache.derby.jdbc.ClientDriver
URL jdbc:derby://localhost:1527/vehicle;create=true
Username app
Password app

9. The general purpose of the Data Access Object (DAO) pattern is to avoid these logic related problems by separating data access logic from business logic and presentation logic.
a) True
b) False
Answer: a
Clarification: This pattern recommends that data access logic be encapsulated in independent modules called data access objects.

10. To access the database with JDBC:-
a) DAO interface
b) DAO Class
c) DataAccess interface
d) None of the mentioned
Answer: a
Clarification: Because your DAO implementation has to connect to the database to execute SQL statements, you may establish database connections by specifying the driver class name, database URL, username, and password.

11. Standard interface defined by the JDBC specification that factories Connection instances.
a) javax.sql.DataAccess
b) javax.sql.DataSource
c) javax.sql.Data
d) javax.sql.DataSourceAccess
Answer: b
Clarification: The javax.sql.DataSource interface is a standard interface defined by the JDBC specification that factories Connection instances.

12. Data source implementations provided by different vendors and projects.
a) C3PO
b) Apache Commons DBCP
c) All of the mentioned
d) None of the mentioned
Answer: c
Clarification: C3PO and Apache Commons DBCP are popular open source options, and most applications servers will provide their own implementation.

13. Spring also provides several convenient but less powerful data source implementations.
a) DriverManagerDataSource
b) DriverManagerData
c) DriverManagerDataAccess
d) DriverManagerDataSourceAccess
Answer: a
Clarification: The simplest one is DriverManagerDataSource, which opens a new connection every time one is requested.

14. SingleConnectionDataSource (a DriverManagerDataSource subclass). As its name indicates, this maintains only a single connection.
a) True
b) False
Answer: a
Clarification: Another data source implementation provided by Spring is SingleConnectionDataSource (a DriverManagerDataSource subclass). As its name indicates, this maintains only a single connection that’s reused all the time and never closed.

15. Which DataSource is not stable in MultiThreaded Environment?
a) DriverManagerDataSource
b) SingleConnectionDataSource
c) All of the mentioned
d) None of the mentione
Answer: c
Clarification: As its name indicates, this maintains only a single connection that’s reused all the time and never closed. Obviously, it is not suitable in a multithreaded environment.

Leave a Reply

Your email address will not be published. Required fields are marked *