Deck 24: Relational Databasesetext Only

Full screen (f)
exit full mode
Question
Insert the statement that would remove the following table from the database.
CREATE TABLE Course
(
Course_ID VARCHAR(11),
Credits VARCHAR(4),
Room_No INT(4)
)
____________________
A.DELETE TABLE Course
B.TRUNCATE TABLE Course
C.DROP Course
D.DROP TABLE Course
Use Space or
up arrow
down arrow
to flip the card.
Question
Which of the following statements is correct?
A.SQL uses double quotes (") to delimit strings.
B.The SQL command INSERT AT adds data to a database
C.SQL is not case sensitive.
D.SQL is a part of the Java API.
Question
Based on the table below, the query that finds the names and zip codes of all customers is _____________________.
Customer table
Based on the table below, the query that finds the names and zip codes of all customers is _____________________. Customer table   A.SELECT ALL Name, Zip FROM Customer B.SELECT Name, Zip C.SELECT * FROM Customer D.SELECT Name, Zip FROM Customer<div style=padding-top: 35px>
A.SELECT ALL Name, Zip FROM Customer
B.SELECT Name, Zip
C.SELECT * FROM Customer
D.SELECT Name, Zip FROM Customer
Question
A ____________ is a reference to a primary key in a linked table.
A.foreign key
B.primary key
C.column headers
D.data type
Question
SQL uses single quotes (') to delimit strings.What is the standard in order to include a single quote in a String? For example: 'Joe's Burgers'
A.Use double quotes (")
B.Use a normal single quote
C.Use the single quote twice
D.Escape with a (\') as in Java
Question
The outcome of a SQL query is a ____________________.
A.table
B.a 2D array of objects
C.list
D.subquery
Question
In database terminology, a column (or combination of columns) that uniquely identifies a row in a table is called a(n) ____.
A.data type
B.attribute
C.primary key
D.column header
Question
A _____________ is a column (or set of columns) whose value uniquely specifies a table record.
A.foreign key
B.primary key
C.column headers
D.data type
Question
Which of the following would be a good primary key for a Course table designed to hold course information for a university?
A.CourseName
B.CourseID
C.CourseCredit
D.CoursePrerequisites
Question
Based on the following table, the query that gets the names and complete mailing addresses of all customers is ____________________.
Customer table
Based on the following table, the query that gets the names and complete mailing addresses of all customers is ____________________. Customer table   A.SELECT * FROM Customer B.SELECT Name, Address, City, State, Zip INTO Customer C.SELECT FROM Customer FIELDS Name, Address, City, State, Zip D.SELECT Name, Address, City, State, Zip FROM Customer<div style=padding-top: 35px>
A.SELECT * FROM Customer
B.SELECT Name, Address, City, State, Zip INTO Customer
C.SELECT FROM Customer FIELDS Name, Address, City, State, Zip
D.SELECT Name, Address, City, State, Zip FROM Customer
Question
In SQL, the _____________ command is used to issue queries that do not modify the database.
A.APPEND
B.UPDATE
C.MODIFY
D.SELECT
Question
Based on the table below, the query that finds all customers who do not live in Pleasantville is _________________.
Customer table
Based on the table below, the query that finds all customers who do not live in Pleasantville is _________________. Customer table   A.SELECT * FROM Customer WHERE City NOT 'Pleasantville' B.SELECT * FROM Customer WHERE NOT (City = 'Pleasantville') C.SELECT * FROM Customer WHERE City <> 'Pleasantville' D.SELECT * FROM Customer WHERE City != 'Pleasantville'<div style=padding-top: 35px>
A.SELECT * FROM Customer WHERE City NOT 'Pleasantville'
B.SELECT * FROM Customer WHERE NOT (City = 'Pleasantville')
C.SELECT * FROM Customer WHERE City <> 'Pleasantville'
D.SELECT * FROM Customer WHERE City != 'Pleasantville'
Question
Based on the customer table below, which of the attributes do you think represents the primary key?
Customer table
Based on the customer table below, which of the attributes do you think represents the primary key? Customer table   A.Address B.Name C.Customer_Number D.Zip<div style=padding-top: 35px>
A.Address
B.Name
C.Customer_Number
D.Zip
Question
In the table below, the ____ correspond(s) to the attributes of a customer in the database.
Customer table
In the table below, the ____ correspond(s) to the attributes of a customer in the database. Customer table   A.foreign key B.primary key C.column headers D.data type<div style=padding-top: 35px>
A.foreign key
B.primary key
C.column headers
D.data type
Question
Based on the table below, insert the statement that queries the database for the names of customers who live in the city of Pleasantville: ______________________
Customer table
Based on the table below, insert the statement that queries the database for the names of customers who live in the city of Pleasantville: ______________________ Customer table   A.SELECT Name FROM Customer WHERE City 'Pleasantville' B.SELECT Name FROM Customer WHERE City == 'Pleasantville' C.SELECT Name FROM Customer WHERE City >< 'Pleasantville' D.SELECT Name FROM Customer WHERE City = 'Pleasantville'<div style=padding-top: 35px>
A.SELECT Name FROM Customer WHERE City 'Pleasantville'
B.SELECT Name FROM Customer WHERE City == 'Pleasantville'
C.SELECT Name FROM Customer WHERE City >< 'Pleasantville'
D.SELECT Name FROM Customer WHERE City = 'Pleasantville'
Question
Complete the following statement, which inserts rows into the following Course table.
____________________ VALUES ('CS221', 'Data Structures', '4', 'J.Jones')
Course table
Complete the following statement, which inserts rows into the following Course table. ____________________ VALUES ('CS221', 'Data Structures', '4', 'J.Jones') Course table   A.INSERT INTO Course table B.INSERT FROM Course C.INSERT INTO Course D.INSERT INTO Table Course<div style=padding-top: 35px>
A.INSERT INTO Course table
B.INSERT FROM Course
C.INSERT INTO Course
D.INSERT INTO Table Course
Question
Which of the following table attributes could be a unique identifier for a person?
A.Name
B.SocialSecurityNumber
C.State
D.Birthday
Question
What is the purpose of a primary key?
A.To establish a link from one table to another
B.To be the first identifier, which does not need to be unique
C.To use a row that uniquely identifies a column
D.To link a column to another column
Question
A ____________ is a set of rows and columns that provides a "window" through which you can see some of the database data.
A.table
B.view
C.window
D.subquery
Question
How does a relational database store information?
A.Arrays
B.Linked Lists
C.Tables
D.Charts
Question
All database URLs have the format:
A.jdbc:subprotocol:driver-specific data
B.jdbc/subprotocol/driver/data
C.oracle.jdbc.driver.OracleDriver
D.c:\jdk1.7.0\db\lib\driver.jar
Question
Based on the table below, which of the following statements will return the number of customers in Michigan (MI)?
Customer table
Based on the table below, which of the following statements will return the number of customers in Michigan (MI)? Customer table   A.SELECT COUNT(*) FROM Customer WHERE State = 'MI' B.SELECT AVG(*) FROM Customer WHERE State = 'MI' C.SELECT MAX(*) FROM Customer WHERE State = 'MI' D.SELECT SUM(*) FROM Customer WHERE State = 'MI'<div style=padding-top: 35px>
A.SELECT COUNT(*) FROM Customer WHERE State = 'MI'
B.SELECT AVG(*) FROM Customer WHERE State = 'MI'
C.SELECT MAX(*) FROM Customer WHERE State = 'MI'
D.SELECT SUM(*) FROM Customer WHERE State = 'MI'
Question
Oracle is an example of a:
A.Heavyweight Java database.
B.Lightweight Java database.
C.Desktop database.
D.Production-quality database.
Question
Which clause allows the joining of multiple tables in SQL?
A.WHERE with multiple items
B.JOIN with multiple items
C.FROM with multiple items
D.WITH with multiple items
Question
Used with the LIKE operator, the ______ symbol matches exactly one character.
A._
B.%
C.?
D.$
Question
Microsoft Access is an example of a:
A.Heavyweight Java database.
B.Lightweight Java database.
C.Desktop database.
D.Production-quality database.
Question
Based on the table below, the SQL statement that changes the address and city of customer 3175, Gregory Adams, to 1337 Parkway Ave and Pembrook, SD, 57462, respectively, is _____________________. Customer table
Based on the table below, the SQL statement that changes the address and city of customer 3175, Gregory Adams, to 1337 Parkway Ave and Pembrook, SD, 57462, respectively, is _____________________. Customer table      <div style=padding-top: 35px> Based on the table below, the SQL statement that changes the address and city of customer 3175, Gregory Adams, to 1337 Parkway Ave and Pembrook, SD, 57462, respectively, is _____________________. Customer table      <div style=padding-top: 35px> Based on the table below, the SQL statement that changes the address and city of customer 3175, Gregory Adams, to 1337 Parkway Ave and Pembrook, SD, 57462, respectively, is _____________________. Customer table      <div style=padding-top: 35px>
Question
The acronym JDBC stands for ________:
A.Joint Data Base Center
B.Java Database Control
C.Joint Database Connectivity
D.Java Database Connectivity
Question
What is the purpose of the LIKE clause?
A.Selects data that fulfills a numerical condition
B.Finds the location of the initial starting point
C.Matches all strings which contains certain characters
D.Tests for equality in ASCII value
Question
What will the following expression match to?
Name LIKE '%e%'
A.all strings in the Name column that end with "e".
B.all strings in the Name column whose second to last letter is an "e".
C.all strings in the Name column that contain the letter "e".
D.all strings in the Name column whose second letter is an "e".
Question
What should be on the class path when you launch a Java program that accesses a database?
A.the JDBC driver
B.the derby.jar file
C.the user name and password
D.the JDK
Question
What should the database.properties file contain so you can connect to a database?
A.a database URL, user name, password
B.a database URL, the program name, and a JDBC driver
C.a database URL, the program name, and database name
D.the JDBC driver path
Question
One of the steps for testing the JDBC driver is:
A.to setup your user account.
B.to find the name of the database URL that your driver expects.
C.to install the JDBC driver program.
D.to change the directory to the JDBC driver directory.
Question
Which SQL command(s) modify the data in a database?
I SELECT
II INSERT
III DELETE
IV UPDATE
A.I, II, III
B.Only II, III
C.II, III, IV
D.Only III, IV
Question
An example of a lightweight database is:
A.Oracle
B.MS Access
C.Apache Derby
D.MySQL
Question
The ______ clause is used to select data that fulfill a condition.
A.SELECT
B.FROM
C.WHEN
D.WHERE
Question
What statement will return the value of a given key from the configuration file? Assume props is of type Properties.
A.String driver = props.getProperty("database.properties");
B.Connection conn = SimpleDataSource.getProperty("database.properties");
C.String driver = props.getProperty("jdbc.driver");
D.Properties props = SampleDataSource.init("jdbc.driver");
Title
What statement will return the value for a given key from the configuration file?
Question
What will the following expression match to?
Name LIKE 'e_%'
A.all strings in the Name column that have at least 3 characters.
B.all strings in the Name column whose first letter is an "e".
C.all strings in the Name column that start with the letter "e" and end with underscore.
D.all strings in the Name column whose second letter is any character.
Question
In SQL, ____ is used to test for equality.
A.EQUAL
B.==
C.=
D.EQUALS
Question
The outcome of a SELECT query is a _________ that you can view and analyze.
A.table
B.list
C.result set
D.subquery
Question
What is the effect of the following statement?
String productCode = result.getString(1);
A.it will return the data in the second column.
B.it will return the data in the first column.
C.it will store the integer 1 as a string in productCode.
D.it will return the name of the column.
Question
An example of a production-quality database is:
A.Oracle
B.MS Access
C.Apache Derby
D.Powerbuilder
Question
In jdbc.URL, the acronym URL stands for:
A.Universal Resource Locator
B.Uniform Resource Locator
C.Universe Resultset Locator
D.Uniform Resultset Locator
Question
If your statement has variable parts, you should use a _________ object.
A.ResultSet
B.ResultSetMetaData
C.PreparedStatement
D.Statement
Question
If your program needs to look at several result sets at the same time, _____.
A.you need to create multiple Statement objects.
B.you can reuse the Statement or PreparedStatement objects
C.you should close the ResultSet before creating a new one.
D.you are not able to see several sets at the same time.
Question
In a Java program, the result of a SQL query is returned in a _____________ object.
A.ResultSet
B.connection
C.view
D.driver
Question
If you want to find out about properties of a result set from an unknown table, you need to use:
A.the ResultSet class.
B.the Statement class.
C.the ResultSetData class.
D.the ResultSetMetaData class.
Question
When you first get a result set from the executeQuery method, you need to call ____ to move to the first row
A.first()
B.start()
C.move()
D.next()
Question
You can use the generic ____ method to execute arbitrary SQL statements.
A.setString()
B.prepareStatement()
C.executeQuery()
D.execute()
Question
Apache Derby is an example of a:
A.Heavyweight Java database.
B.Lightweight Java database.
C.Desktop database.
D.Production-quality database.
Question
What is wrong with the following statement?
ResultSet result = statement.execute("SELECT * FROM emp WHERE empNum = '5'");
A.ResultSet should be String
B.execute should be executeQuery
C.execute should be prepareStatement
D.5 should not be used as an empNum value
Question
What does the execute method return?
A.ResultSet
B.Query
C.RecordSet
D.boolean
Question
What will the following command do?
java -classpath derby.sql;.ExecSQL database.properties Product.sql
A.It will execute the statements in the database.properties file.
B.It will execute the statements in the derby.sql file.
C.It will execute the statements in the Product.sql file.
D.It will act as an interactive testing tool only.
Question
The ___ symbol in the query string denotes variables that you fill in when you make an actual query
A.?
B.*
C.!
D.::
Title
The ___ symbol in the query string denotes variables filled by an actual quer
Question
What is wrong with the following statement?
boolean result = statement.execute("SELECT * FROM emp WHERE empNum = '?'");
A.boolean should be ResultSet
B.execute should be executeQuery
C.execute should be prepareStatement
D.? should be an integer
Question
What will the following command do?
java -classpath derby.sql;.ExecSQL database.properties
A.It will execute the statements in the database.properties file.
B.It will execute the statements in the derby.sql file.
C.It will compile the statements in the derby.sql file.
D.It will use ExecSQL program as an interactive testing tool.
Question
Which Java statement connects to a database using a Connection object?
A.Connection conn = new Connection(url, username, password);
B.Conenction conn = DriverManager.getConnection();
C.Connection conn = DriverManager.connect(url, username, password);
D.Connection conn = DriverManager.getConnection(url, username, password);
Question
An example of a desktop database is:
A.Oracle
B.MS Access
C.Apache Derby
D.MySQL
Question
Why should we use try-with-resources to open a Connection to a database?
A.To commit the changes
B.To display the ResultSet
C.To display the metadata
D.To close the connection
Question
A ______________ object can create statement objects that are used to execute SQL commands.
A.ResultSet
B.Connection
C.JDBC
D.Driver
Question
When you execute a rollback:
A.the temporary data are made permanent.
B.the temporary tables are simply discarded.
C.the database stores the changes in a temporary table.
D.it will commit all the updates.
Section
Reference 1: 24.5 Application: Entering an Invoice
Question
When you close a connection:
A.it closes the connection only.
B.it closes the connection and the associated result set.
C.it closes the connection and the associated statement.
D.it closes the connection and closes all statements and result sets.
Question
Metadata are ______
A.data about an object.
B.the properties of a result set.
C.the objects that are used to execute the SQL commands.
D.data about a connection.
Question
In what format does the SQL query return a result?
A.XPath syntax
B.ResultSet object
C.A String separated by colons
D.An array of results
Question
What does the following statement do?
String prodCode = nextLine(in, "Product Code (D=Done, L=List)");
A.It will store the string "Product Code (D=Done, L=List)" in the variable in.
B.It will display "in, Product Code (D=Done, L=List)" on the screen.
C.It will display the contents of the variable in on the screen.
D.It will read the user's input and store it in the object prodCode.
Question
"SQL injection attacks" have been responsible for many cases of data theft.One of the solutions for preventing these attacks is:
A.Never use double quotes in the query.
B.Never use single quotes in the query.
C.Never add a string to a query that you didn't type yourself.
D.Never add a number to a query that you didn't type yourself.
Question
To get the number of columns in a result set, you use _________ method of the ResultSetMetaData class.
A.getColumnInt()
B.getColumnsCount()
C.getCount()
D.getColumnCount()
Question
Database tables store rows that contain the following except
A.strings
B.fundamental data types
C.arbitrary objects
D.numbers
Title
Database tables store rows that contain the following excep
Question
To fetch a column in a result set that stores prices, use the ______ method.
A.nextInt()
B.getInt()
C.nextDouble()
D.getDouble()
Question
When you are done with a Statement object, _______.
A.you should close it and you must close the associated result set as well.
B.you should not close it and should not close the associated result set.
C.you should close it and that automatically closes the associated result set.
D.you should only close the associated result set.
Title
What to do when you are done with the Statement objec
Question
If you encounter an error during updating a transaction, then call the ______ method:
A.undo
B.takeback
C.rollaround
D.rollback
Question
What is the main purpose of the Connection object?
A.Accesses a database from a Java program
B.Combines multiple data tables
C.Skips the loading step of the database driver class
D.Manually loads the database driver class
Question
An important part of database processing is transaction handling.What is a transaction?
A.A set of data that is translated into the required language and then added to the database
B.A set of database transfers to another database
C.A set of database updates that may have some parts successful
D.A set of database updates that should either succeed fully or not happen at all
Question
Which import statement will allow you to use a SQLException object?
A.import javax.swing.SQLException;
B.import java.sql.SQLException;
C.import java.util.SQLException;
D.import java.io.SQLException;
Question
The ______ class has a next method to visit the next row of a query result.
A.Scanner
B.Statement
C.ResultSet
D.Connection
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/75
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 24: Relational Databasesetext Only
1
Insert the statement that would remove the following table from the database.
CREATE TABLE Course
(
Course_ID VARCHAR(11),
Credits VARCHAR(4),
Room_No INT(4)
)
____________________
A.DELETE TABLE Course
B.TRUNCATE TABLE Course
C.DROP Course
D.DROP TABLE Course
DROP TABLE Course
2
Which of the following statements is correct?
A.SQL uses double quotes (") to delimit strings.
B.The SQL command INSERT AT adds data to a database
C.SQL is not case sensitive.
D.SQL is a part of the Java API.
SQL is not case sensitive.
3
Based on the table below, the query that finds the names and zip codes of all customers is _____________________.
Customer table
Based on the table below, the query that finds the names and zip codes of all customers is _____________________. Customer table   A.SELECT ALL Name, Zip FROM Customer B.SELECT Name, Zip C.SELECT * FROM Customer D.SELECT Name, Zip FROM Customer
A.SELECT ALL Name, Zip FROM Customer
B.SELECT Name, Zip
C.SELECT * FROM Customer
D.SELECT Name, Zip FROM Customer
SELECT Name, Zip FROM Customer
4
A ____________ is a reference to a primary key in a linked table.
A.foreign key
B.primary key
C.column headers
D.data type
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
5
SQL uses single quotes (') to delimit strings.What is the standard in order to include a single quote in a String? For example: 'Joe's Burgers'
A.Use double quotes (")
B.Use a normal single quote
C.Use the single quote twice
D.Escape with a (\') as in Java
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
6
The outcome of a SQL query is a ____________________.
A.table
B.a 2D array of objects
C.list
D.subquery
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
7
In database terminology, a column (or combination of columns) that uniquely identifies a row in a table is called a(n) ____.
A.data type
B.attribute
C.primary key
D.column header
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
8
A _____________ is a column (or set of columns) whose value uniquely specifies a table record.
A.foreign key
B.primary key
C.column headers
D.data type
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following would be a good primary key for a Course table designed to hold course information for a university?
A.CourseName
B.CourseID
C.CourseCredit
D.CoursePrerequisites
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
10
Based on the following table, the query that gets the names and complete mailing addresses of all customers is ____________________.
Customer table
Based on the following table, the query that gets the names and complete mailing addresses of all customers is ____________________. Customer table   A.SELECT * FROM Customer B.SELECT Name, Address, City, State, Zip INTO Customer C.SELECT FROM Customer FIELDS Name, Address, City, State, Zip D.SELECT Name, Address, City, State, Zip FROM Customer
A.SELECT * FROM Customer
B.SELECT Name, Address, City, State, Zip INTO Customer
C.SELECT FROM Customer FIELDS Name, Address, City, State, Zip
D.SELECT Name, Address, City, State, Zip FROM Customer
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
11
In SQL, the _____________ command is used to issue queries that do not modify the database.
A.APPEND
B.UPDATE
C.MODIFY
D.SELECT
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
12
Based on the table below, the query that finds all customers who do not live in Pleasantville is _________________.
Customer table
Based on the table below, the query that finds all customers who do not live in Pleasantville is _________________. Customer table   A.SELECT * FROM Customer WHERE City NOT 'Pleasantville' B.SELECT * FROM Customer WHERE NOT (City = 'Pleasantville') C.SELECT * FROM Customer WHERE City <> 'Pleasantville' D.SELECT * FROM Customer WHERE City != 'Pleasantville'
A.SELECT * FROM Customer WHERE City NOT 'Pleasantville'
B.SELECT * FROM Customer WHERE NOT (City = 'Pleasantville')
C.SELECT * FROM Customer WHERE City <> 'Pleasantville'
D.SELECT * FROM Customer WHERE City != 'Pleasantville'
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
13
Based on the customer table below, which of the attributes do you think represents the primary key?
Customer table
Based on the customer table below, which of the attributes do you think represents the primary key? Customer table   A.Address B.Name C.Customer_Number D.Zip
A.Address
B.Name
C.Customer_Number
D.Zip
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
14
In the table below, the ____ correspond(s) to the attributes of a customer in the database.
Customer table
In the table below, the ____ correspond(s) to the attributes of a customer in the database. Customer table   A.foreign key B.primary key C.column headers D.data type
A.foreign key
B.primary key
C.column headers
D.data type
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
15
Based on the table below, insert the statement that queries the database for the names of customers who live in the city of Pleasantville: ______________________
Customer table
Based on the table below, insert the statement that queries the database for the names of customers who live in the city of Pleasantville: ______________________ Customer table   A.SELECT Name FROM Customer WHERE City 'Pleasantville' B.SELECT Name FROM Customer WHERE City == 'Pleasantville' C.SELECT Name FROM Customer WHERE City >< 'Pleasantville' D.SELECT Name FROM Customer WHERE City = 'Pleasantville'
A.SELECT Name FROM Customer WHERE City 'Pleasantville'
B.SELECT Name FROM Customer WHERE City == 'Pleasantville'
C.SELECT Name FROM Customer WHERE City >< 'Pleasantville'
D.SELECT Name FROM Customer WHERE City = 'Pleasantville'
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
16
Complete the following statement, which inserts rows into the following Course table.
____________________ VALUES ('CS221', 'Data Structures', '4', 'J.Jones')
Course table
Complete the following statement, which inserts rows into the following Course table. ____________________ VALUES ('CS221', 'Data Structures', '4', 'J.Jones') Course table   A.INSERT INTO Course table B.INSERT FROM Course C.INSERT INTO Course D.INSERT INTO Table Course
A.INSERT INTO Course table
B.INSERT FROM Course
C.INSERT INTO Course
D.INSERT INTO Table Course
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following table attributes could be a unique identifier for a person?
A.Name
B.SocialSecurityNumber
C.State
D.Birthday
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
18
What is the purpose of a primary key?
A.To establish a link from one table to another
B.To be the first identifier, which does not need to be unique
C.To use a row that uniquely identifies a column
D.To link a column to another column
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
19
A ____________ is a set of rows and columns that provides a "window" through which you can see some of the database data.
A.table
B.view
C.window
D.subquery
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
20
How does a relational database store information?
A.Arrays
B.Linked Lists
C.Tables
D.Charts
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
21
All database URLs have the format:
A.jdbc:subprotocol:driver-specific data
B.jdbc/subprotocol/driver/data
C.oracle.jdbc.driver.OracleDriver
D.c:\jdk1.7.0\db\lib\driver.jar
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
22
Based on the table below, which of the following statements will return the number of customers in Michigan (MI)?
Customer table
Based on the table below, which of the following statements will return the number of customers in Michigan (MI)? Customer table   A.SELECT COUNT(*) FROM Customer WHERE State = 'MI' B.SELECT AVG(*) FROM Customer WHERE State = 'MI' C.SELECT MAX(*) FROM Customer WHERE State = 'MI' D.SELECT SUM(*) FROM Customer WHERE State = 'MI'
A.SELECT COUNT(*) FROM Customer WHERE State = 'MI'
B.SELECT AVG(*) FROM Customer WHERE State = 'MI'
C.SELECT MAX(*) FROM Customer WHERE State = 'MI'
D.SELECT SUM(*) FROM Customer WHERE State = 'MI'
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
23
Oracle is an example of a:
A.Heavyweight Java database.
B.Lightweight Java database.
C.Desktop database.
D.Production-quality database.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
24
Which clause allows the joining of multiple tables in SQL?
A.WHERE with multiple items
B.JOIN with multiple items
C.FROM with multiple items
D.WITH with multiple items
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
25
Used with the LIKE operator, the ______ symbol matches exactly one character.
A._
B.%
C.?
D.$
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
26
Microsoft Access is an example of a:
A.Heavyweight Java database.
B.Lightweight Java database.
C.Desktop database.
D.Production-quality database.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
27
Based on the table below, the SQL statement that changes the address and city of customer 3175, Gregory Adams, to 1337 Parkway Ave and Pembrook, SD, 57462, respectively, is _____________________. Customer table
Based on the table below, the SQL statement that changes the address and city of customer 3175, Gregory Adams, to 1337 Parkway Ave and Pembrook, SD, 57462, respectively, is _____________________. Customer table      Based on the table below, the SQL statement that changes the address and city of customer 3175, Gregory Adams, to 1337 Parkway Ave and Pembrook, SD, 57462, respectively, is _____________________. Customer table      Based on the table below, the SQL statement that changes the address and city of customer 3175, Gregory Adams, to 1337 Parkway Ave and Pembrook, SD, 57462, respectively, is _____________________. Customer table
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
28
The acronym JDBC stands for ________:
A.Joint Data Base Center
B.Java Database Control
C.Joint Database Connectivity
D.Java Database Connectivity
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
29
What is the purpose of the LIKE clause?
A.Selects data that fulfills a numerical condition
B.Finds the location of the initial starting point
C.Matches all strings which contains certain characters
D.Tests for equality in ASCII value
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
30
What will the following expression match to?
Name LIKE '%e%'
A.all strings in the Name column that end with "e".
B.all strings in the Name column whose second to last letter is an "e".
C.all strings in the Name column that contain the letter "e".
D.all strings in the Name column whose second letter is an "e".
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
31
What should be on the class path when you launch a Java program that accesses a database?
A.the JDBC driver
B.the derby.jar file
C.the user name and password
D.the JDK
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
32
What should the database.properties file contain so you can connect to a database?
A.a database URL, user name, password
B.a database URL, the program name, and a JDBC driver
C.a database URL, the program name, and database name
D.the JDBC driver path
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
33
One of the steps for testing the JDBC driver is:
A.to setup your user account.
B.to find the name of the database URL that your driver expects.
C.to install the JDBC driver program.
D.to change the directory to the JDBC driver directory.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
34
Which SQL command(s) modify the data in a database?
I SELECT
II INSERT
III DELETE
IV UPDATE
A.I, II, III
B.Only II, III
C.II, III, IV
D.Only III, IV
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
35
An example of a lightweight database is:
A.Oracle
B.MS Access
C.Apache Derby
D.MySQL
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
36
The ______ clause is used to select data that fulfill a condition.
A.SELECT
B.FROM
C.WHEN
D.WHERE
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
37
What statement will return the value of a given key from the configuration file? Assume props is of type Properties.
A.String driver = props.getProperty("database.properties");
B.Connection conn = SimpleDataSource.getProperty("database.properties");
C.String driver = props.getProperty("jdbc.driver");
D.Properties props = SampleDataSource.init("jdbc.driver");
Title
What statement will return the value for a given key from the configuration file?
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
38
What will the following expression match to?
Name LIKE 'e_%'
A.all strings in the Name column that have at least 3 characters.
B.all strings in the Name column whose first letter is an "e".
C.all strings in the Name column that start with the letter "e" and end with underscore.
D.all strings in the Name column whose second letter is any character.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
39
In SQL, ____ is used to test for equality.
A.EQUAL
B.==
C.=
D.EQUALS
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
40
The outcome of a SELECT query is a _________ that you can view and analyze.
A.table
B.list
C.result set
D.subquery
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
41
What is the effect of the following statement?
String productCode = result.getString(1);
A.it will return the data in the second column.
B.it will return the data in the first column.
C.it will store the integer 1 as a string in productCode.
D.it will return the name of the column.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
42
An example of a production-quality database is:
A.Oracle
B.MS Access
C.Apache Derby
D.Powerbuilder
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
43
In jdbc.URL, the acronym URL stands for:
A.Universal Resource Locator
B.Uniform Resource Locator
C.Universe Resultset Locator
D.Uniform Resultset Locator
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
44
If your statement has variable parts, you should use a _________ object.
A.ResultSet
B.ResultSetMetaData
C.PreparedStatement
D.Statement
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
45
If your program needs to look at several result sets at the same time, _____.
A.you need to create multiple Statement objects.
B.you can reuse the Statement or PreparedStatement objects
C.you should close the ResultSet before creating a new one.
D.you are not able to see several sets at the same time.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
46
In a Java program, the result of a SQL query is returned in a _____________ object.
A.ResultSet
B.connection
C.view
D.driver
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
47
If you want to find out about properties of a result set from an unknown table, you need to use:
A.the ResultSet class.
B.the Statement class.
C.the ResultSetData class.
D.the ResultSetMetaData class.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
48
When you first get a result set from the executeQuery method, you need to call ____ to move to the first row
A.first()
B.start()
C.move()
D.next()
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
49
You can use the generic ____ method to execute arbitrary SQL statements.
A.setString()
B.prepareStatement()
C.executeQuery()
D.execute()
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
50
Apache Derby is an example of a:
A.Heavyweight Java database.
B.Lightweight Java database.
C.Desktop database.
D.Production-quality database.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
51
What is wrong with the following statement?
ResultSet result = statement.execute("SELECT * FROM emp WHERE empNum = '5'");
A.ResultSet should be String
B.execute should be executeQuery
C.execute should be prepareStatement
D.5 should not be used as an empNum value
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
52
What does the execute method return?
A.ResultSet
B.Query
C.RecordSet
D.boolean
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
53
What will the following command do?
java -classpath derby.sql;.ExecSQL database.properties Product.sql
A.It will execute the statements in the database.properties file.
B.It will execute the statements in the derby.sql file.
C.It will execute the statements in the Product.sql file.
D.It will act as an interactive testing tool only.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
54
The ___ symbol in the query string denotes variables that you fill in when you make an actual query
A.?
B.*
C.!
D.::
Title
The ___ symbol in the query string denotes variables filled by an actual quer
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
55
What is wrong with the following statement?
boolean result = statement.execute("SELECT * FROM emp WHERE empNum = '?'");
A.boolean should be ResultSet
B.execute should be executeQuery
C.execute should be prepareStatement
D.? should be an integer
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
56
What will the following command do?
java -classpath derby.sql;.ExecSQL database.properties
A.It will execute the statements in the database.properties file.
B.It will execute the statements in the derby.sql file.
C.It will compile the statements in the derby.sql file.
D.It will use ExecSQL program as an interactive testing tool.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
57
Which Java statement connects to a database using a Connection object?
A.Connection conn = new Connection(url, username, password);
B.Conenction conn = DriverManager.getConnection();
C.Connection conn = DriverManager.connect(url, username, password);
D.Connection conn = DriverManager.getConnection(url, username, password);
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
58
An example of a desktop database is:
A.Oracle
B.MS Access
C.Apache Derby
D.MySQL
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
59
Why should we use try-with-resources to open a Connection to a database?
A.To commit the changes
B.To display the ResultSet
C.To display the metadata
D.To close the connection
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
60
A ______________ object can create statement objects that are used to execute SQL commands.
A.ResultSet
B.Connection
C.JDBC
D.Driver
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
61
When you execute a rollback:
A.the temporary data are made permanent.
B.the temporary tables are simply discarded.
C.the database stores the changes in a temporary table.
D.it will commit all the updates.
Section
Reference 1: 24.5 Application: Entering an Invoice
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
62
When you close a connection:
A.it closes the connection only.
B.it closes the connection and the associated result set.
C.it closes the connection and the associated statement.
D.it closes the connection and closes all statements and result sets.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
63
Metadata are ______
A.data about an object.
B.the properties of a result set.
C.the objects that are used to execute the SQL commands.
D.data about a connection.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
64
In what format does the SQL query return a result?
A.XPath syntax
B.ResultSet object
C.A String separated by colons
D.An array of results
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
65
What does the following statement do?
String prodCode = nextLine(in, "Product Code (D=Done, L=List)");
A.It will store the string "Product Code (D=Done, L=List)" in the variable in.
B.It will display "in, Product Code (D=Done, L=List)" on the screen.
C.It will display the contents of the variable in on the screen.
D.It will read the user's input and store it in the object prodCode.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
66
"SQL injection attacks" have been responsible for many cases of data theft.One of the solutions for preventing these attacks is:
A.Never use double quotes in the query.
B.Never use single quotes in the query.
C.Never add a string to a query that you didn't type yourself.
D.Never add a number to a query that you didn't type yourself.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
67
To get the number of columns in a result set, you use _________ method of the ResultSetMetaData class.
A.getColumnInt()
B.getColumnsCount()
C.getCount()
D.getColumnCount()
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
68
Database tables store rows that contain the following except
A.strings
B.fundamental data types
C.arbitrary objects
D.numbers
Title
Database tables store rows that contain the following excep
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
69
To fetch a column in a result set that stores prices, use the ______ method.
A.nextInt()
B.getInt()
C.nextDouble()
D.getDouble()
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
70
When you are done with a Statement object, _______.
A.you should close it and you must close the associated result set as well.
B.you should not close it and should not close the associated result set.
C.you should close it and that automatically closes the associated result set.
D.you should only close the associated result set.
Title
What to do when you are done with the Statement objec
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
71
If you encounter an error during updating a transaction, then call the ______ method:
A.undo
B.takeback
C.rollaround
D.rollback
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
72
What is the main purpose of the Connection object?
A.Accesses a database from a Java program
B.Combines multiple data tables
C.Skips the loading step of the database driver class
D.Manually loads the database driver class
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
73
An important part of database processing is transaction handling.What is a transaction?
A.A set of data that is translated into the required language and then added to the database
B.A set of database transfers to another database
C.A set of database updates that may have some parts successful
D.A set of database updates that should either succeed fully or not happen at all
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
74
Which import statement will allow you to use a SQLException object?
A.import javax.swing.SQLException;
B.import java.sql.SQLException;
C.import java.util.SQLException;
D.import java.io.SQLException;
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
75
The ______ class has a next method to visit the next row of a query result.
A.Scanner
B.Statement
C.ResultSet
D.Connection
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 75 flashcards in this deck.