Unit 3: File I/O and JDBC - Subjective Questions

CSE406 — Advanced Java Programming • Practice Questions with Detailed Answers

20 questions

1

Define the Path interface in Java NIO.2. Explain how it is used to represent and operate on file and directory paths, with suitable examples.

2

Explain the difference between absolute paths and relative paths in Java. How can the Path interface convert one form into the other?

3

Describe the path manipulation methods resolve(), relativize(), and normalize() provided by the Path interface.

4

Explain how the Files class is used to test the properties of files and directories in Java NIO.2.

5

Describe the procedures for creating and deleting files and directories using the Files class. Mention important exceptions and precautions.

6

Explain how to copy and move files or directories using Files.copy() and Files.move(). Discuss the role of standard copy options.

7

Explain how the Stream API can be used with NIO.2 to list, walk, and process files in a directory tree.

8

Compare Files.list(), Files.walk(), and Files.find(). State the situations in which each method is most appropriate.

9

Describe the layout and major components of the JDBC API. Explain the roles of DriverManager, Connection, Statement, PreparedStatement, CallableStatement, and ResultSet.

10

Explain the steps involved in connecting a Java application to a database using a JDBC driver.

11

What is a JDBC URL? Explain its structure and describe the information it provides to the JDBC driver.

12

Explain how SQL queries are submitted and how results are obtained using JDBC. Include the difference between executeQuery(), executeUpdate(), and execute().

13

Explain the structure and navigation of a JDBC ResultSet. How are column values retrieved from it?

14

Why is PreparedStatement preferred over Statement for parameterized SQL? Explain its security and performance advantages with an example.

15

Explain how JDBC driver information can be specified externally. Discuss the use of configuration files, environment variables, and system properties.

16

Describe the JDBC transaction model. Explain auto-commit, commit(), rollback(), and the importance of transactions during CRUD operations.

17

Explain how to implement the Create, Read, Update, and Delete operations using JDBC. Provide representative SQL and JDBC methods for each operation.

18

Explain JDBC resource management using try-with-resources. Why should Connection, Statement, and ResultSet objects be closed?

19

Distinguish between Statement, PreparedStatement, and CallableStatement in JDBC.

20

What is JDBC metadata? Explain the purpose of DatabaseMetaData and ResultSetMetaData.