b2-c09 Flashcards
Name the five key interfaces of JDBC
Driver: Establishes a connection to the database
Connection: Sends commands to a database
PreparedStatement: Executes a SQL query
CallableStatement: Executes commands stored in the database
ResultSet: Reads results of a query
What does the NIO.2 acronym stand for?
The second version of the Non-blocking Input/Output API. It is sometimes referred to as the “New I/O.”
Which legacy class is NIO.2 / java.nio.file.Path is intended to replace?
java.io.File
What are the similarities between java.nio.file.Path and java.io.File?
- Both may refer to an absolute path or relative path within the file system.
- Both may refer to a file or a directory.
What are the differences between java.nio.file.Path and java.io.File?
Unlike the java.io.File class, the Path interface contains support for creating, detecting, and navigating symbolic link.
What is symbolic link?
A symbolic link is a special file within a file system that serves as a reference or pointer to another file or directory
In general, symbolic links are transparent to the user, as the operating system takes care of resolving the reference to the actual file.
True/False
True
What is the rationale for making Path an interface as opposed to a class
When a Path is created, the JVM returns a file system–specific implementation, such as a Windows or Unix Path class.
List six ways to create Path object
With/from:
- Path interface - Path.of()
- Paths class - Paths.get()
- URI class
- FileSystem class
- java.io.File class
- String values
The simplest and most straightforward way to obtain a Path object is to use ________________________________________________________.
the static factory method defined within the Path interface.
public static Path of(String first, String… more)
Describe absolute path and relative path
- if path starts with / it is absolute (Unix)
- if path starts with a drive letter (c:), it is absolute (Windows)
- otherwise, it is relative
Path.of() can take a varargs besides a connected string of path elements. What is the benefit of this capability?
The advantage of the varargs is that it is more robust, as it inserts the proper operating system path separator for you.
Describe Path.of()
-a static method defined in Path interface
-Path factory method
public static Path of(String first, String… more)
How can a Path object be constructed from String values?
Relative
Path path1 = Path.of(“pandas/cuddly.png”);
Absolute -Windows
Path path2 = Path.of(“c:\zooinfo\November\employees.txt”);
Absolute - Unix
Path path3 = Path.of(“/home/zoodirectory
What parameters types does Path.of() take?
- String values
Path path1 = Path.of(“pandas/cuddly.png”);
Path path2 = Path.of(“c:\zooinfo\November\employees.txt”);
Path path3 = Path.of(“/home/zoodirectory
Or
- Varargs
Path path1 = Path.of(“pandas”, “cuddly.png”);
Path path2 = Path.of(“c:”, “zooinfo”, “November”, “employees.txt”);
Path path3 = Path.of(“/”, “home”, “zoodirectory”);