Deck 22: Relational Databases

Full screen (f)
exit full mode
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
Use Space or
up arrow
down arrow
to flip the card.
Question
Based on the table below, which of the following statements will return the number of customers in Michigan (MI)?
Customer table
<strong>Based on the table below, which of the following statements will return the number of customers in Michigan (MI)? Customer table  </strong> 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
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 all customers who do not live in Pleasantville is _________________.
Customer table
<strong>Based on the table below, the query that finds all customers who do not live in Pleasantville is _________________. Customer table  </strong> 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
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
In the table below, the ____ correspond(s) to the attributes of a customer in the database.
Customer table
<strong>In the table below, the ____ correspond(s) to the attributes of a customer in the database. Customer table  </strong> 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 following table, the query that gets the names and complete mailing addresses of all customers is ____________________.
Customer table
<strong>Based on the following table, the query that gets the names and complete mailing addresses of all customers is ____________________. Customer table  </strong> 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
Based on the table below, the query that finds the names and zip codes of all customers is _____________________.
Customer table
<strong>Based on the table below, the query that finds the names and zip codes of all customers is _____________________. Customer table  </strong> 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
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
Which of the following table attributes could be a unique identifier for a person?

A) Name b) SocialSecurityNumber
C) State
D) Birthday
Question
Based on the customer table below, which of the attributes do you think represents the primary key?
Customer table
<strong>Based on the customer table below, which of the attributes do you think represents the primary key? Customer table  </strong> A) Address b) Name C) Customer_Number D) Zip <div style=padding-top: 35px>

A) Address b) Name
C) Customer_Number
D) Zip
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
Complete the following statement, which inserts rows into the following Course table.
____________________ VALUES ('CS221', 'Data Structures', '4', 'J. Jones')
Course table
<strong>Complete the following statement, which inserts rows into the following Course table. ____________________ VALUES ('CS221', 'Data Structures', '4', 'J. Jones') Course table  </strong> 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
In SQL, the _____________ command is used to issue queries.

A) QUERY
B) UPDATE
C) START
D) SELECT
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
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
In SQL, ____ is used to test for equality.

A) EQUAL b) ==
C) =
D) EQUALS
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
<strong>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  </strong> 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
The outcome of a SQL query is a ____________________.

A) table
B) view of the data
C) list
D) subquery
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
In a Java program, the result of a SQL query is returned in a(n) _____________ object.

A) ResultSet
B) connection
C) view
D) driver
Question
The acronym JDBC stands for ________:

A) Joint Data Base Center
B) Java Database Control
C) Joint Database Connectivity
D) Java Database Connectivity
Question
The ___ symbol in the query string denotes variables that you fill in when you make an actual query

A) ?
B) *
C) !
D) ::
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
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");
Question
A ______________ object can create statement objects that are used to execute SQL commands.

A) ResultSet
B) Connection
C) JDBC
D) Driver
Question
If your statement has variable parts, you should use a _________ object.

A) ResultSet
B) ResultSetMetaData
C) PreparedStatement
D) Statement
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 one reason why you need a finally clause after a try/catch sequence that accesses a database?

A) To commit the changes
B) To display the ResultSet
C) To display the metadata
D) To close the connection
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
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
<strong>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  </strong> A) UPDATE Customer Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE FirstName = 'Gregory' AND LastName = 'Adams' B) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE FirstName = 'Gregory' AND LastName = 'Adams' C) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE Name = 'Gregory Adams' D) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' <div style=padding-top: 35px>

A) UPDATE Customer Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE FirstName = 'Gregory' AND LastName = 'Adams'
B) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE FirstName = 'Gregory' AND LastName = 'Adams'
C) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE Name = 'Gregory Adams'
D) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462'
Question
The following command will compile a Java program called TestDB:

A) java TestDB.class
B) java TestDB.java
C) javac TestDB.java
D) javac TestDB.class
Question
If you encounter an error during updating a transaction, then call the ______ method:

A) undo
B) takeback
C) rollaround
D) rollback
Question
Given the following two statements, what does the call to the next() method return?
ResultSet result = statement.executeQuery();
Result.next();

A) The next record in the result.
B) true or false.
C) The primary key.
D) The next column in the table.
Question
An example of a lightweight database is:

A) Oracle
B) MS Access
C) Apache Derby
D) MySQL
Question
Based on the table below, the SQL statement that changes the last name of customer 3175 to Michael is _____________________.
Customer table
<strong>Based on the table below, the SQL statement that changes the last name of customer 3175 to Michael is _____________________. Customer table  </strong> A) UPDATE Customer SET LastName = 'Michael' WHERE Customer_Number = 3175 B) UPDATE Customer SET Customer_Number = 3175 WHERE LastName = 'Michael' C) UPDATE Customer table SET LastName = 'Michael' WHERE Customer_Number = 3175 D) UPDATE Customer SET FirstName = 'Susan' WHERE LastName = 'Michael' <div style=padding-top: 35px>

A) UPDATE Customer SET LastName = 'Michael' WHERE Customer_Number = 3175
B) UPDATE Customer SET Customer_Number = 3175 WHERE LastName = 'Michael'
C) UPDATE Customer table SET LastName = 'Michael' WHERE Customer_Number = 3175
D) UPDATE Customer SET FirstName = 'Susan' WHERE LastName = 'Michael'
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.
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
Which SQL command(s) modify the data in a database?
I SELECT
II INSERT
III DELETE
IV UPDATE

A) I, II, III
B) II, III
C) II, III, IV
D) III, IV
Question
Microsoft Access is an example of a:

A) Heavyweight Java database.
B) Lightweight Java database.
C) Desktop database.
D) Production-quality database.
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
An example of a production-quality database is:

A) Oracle
B) MS Access
C) Apache Derby
D) Powerbuilder
Question
What does the execute method return?

A) ResultSet
B) Query
C) RecordSet
D) boolean
Question
Apache Derby is an example of a:

A) Heavyweight Java database.
B) Lightweight Java database.
C) Desktop database.
D) Production-quality database.
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
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
What is the effect of the following statement?
String product_code = 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 the product_code.
D) it will return the name of the column.
Question
An example of a desktop database is:

A) Oracle
B) MS Access
C) Apache Derby
D) MySQL
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
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
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
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
You can use the generic ____ method to execute arbitrary SQL statements.

A) setString()
B) prepareStatement()
C) executeQuery()
D) execute()
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.
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
The ______ class has a next method to visit the next row of a query result.

A) Scanner
B) Statement
C) ResultSet
D) Connection
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
Oracle is an example of a:

A) Heavyweight Java database.
B) Lightweight Java database.
C) Desktop database.
D) Production-quality database.
Question
A ______ lets you fetch a query result, one row at a time.

A) Query
B) Statement
C) ResultSet
D) PreparedStatement
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
Used with the LIKE operator, the ______ symbol matches exactly one character.

A) _
B) %
C) ?
D) $
Question
To fetch a column in a result set that stores the number of children, use the ______ method.

A) nextInt()
B) getInt()
C) nextDouble()
D) getDouble()
Question
Beginners are afraid of issuing complex SQL queries, so they are ______

A) throwing away a major benefit of a relational database.
B) throwing an exception called badQueryException.
C) doing the right thing by avoiding those queries for efficiency.
D) taking advantage of the SQL benefits.
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
To fetch a column in a result set that stores prices, use the ______ method.

A) nextInt()
B) getInt()
C) nextDouble()
D) getDouble()
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
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
Database tables store rows that contain the following except

A) strings
B) fundamental data types
C) arbitrary objects
D) numbers
Question
The ______ clause is used to select data that fulfill a condition

A) SELECT
B) FROM
C) WHEN
D) WHERE
Question
"SQL injection attacks" have been responsible for many cases of data theft. One of the solutions 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
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 start with the letter "e".
D) all strings in the Name column whose second letter is an "e".
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
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
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
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 22: Relational Databases
1
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
B
2
Based on the table below, which of the following statements will return the number of customers in Michigan (MI)?
Customer table
<strong>Based on the table below, which of the following statements will return the number of customers in Michigan (MI)? Customer table  </strong> 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'
A
3
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.
C
4
Based on the table below, the query that finds all customers who do not live in Pleasantville is _________________.
Customer table
<strong>Based on the table below, the query that finds all customers who do not live in Pleasantville is _________________. Customer table  </strong> 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
5
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
6
In the table below, the ____ correspond(s) to the attributes of a customer in the database.
Customer table
<strong>In the table below, the ____ correspond(s) to the attributes of a customer in the database. Customer table  </strong> 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
7
Based on the following table, the query that gets the names and complete mailing addresses of all customers is ____________________.
Customer table
<strong>Based on the following table, the query that gets the names and complete mailing addresses of all customers is ____________________. Customer table  </strong> 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
8
Based on the table below, the query that finds the names and zip codes of all customers is _____________________.
Customer table
<strong>Based on the table below, the query that finds the names and zip codes of all customers is _____________________. Customer table  </strong> 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
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
9
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
10
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
11
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
12
Based on the customer table below, which of the attributes do you think represents the primary key?
Customer table
<strong>Based on the customer table below, which of the attributes do you think represents the primary key? Customer table  </strong> 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
13
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
14
Complete the following statement, which inserts rows into the following Course table.
____________________ VALUES ('CS221', 'Data Structures', '4', 'J. Jones')
Course table
<strong>Complete the following statement, which inserts rows into the following Course table. ____________________ VALUES ('CS221', 'Data Structures', '4', 'J. Jones') Course table  </strong> 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
15
In SQL, the _____________ command is used to issue queries.

A) QUERY
B) UPDATE
C) START
D) SELECT
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
16
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
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
17
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
18
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
19
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
<strong>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  </strong> 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
20
The outcome of a SQL query is a ____________________.

A) table
B) view of the data
C) list
D) subquery
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
In a Java program, the result of a SQL query is returned in a(n) _____________ 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
23
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
24
The ___ symbol in the query string denotes variables that you fill in when you make an actual query

A) ?
B) *
C) !
D) ::
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
25
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
26
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");
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
27
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
28
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
29
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
30
What is one reason why you need a finally clause after a try/catch sequence that accesses 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
31
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
32
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
<strong>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  </strong> A) UPDATE Customer Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE FirstName = 'Gregory' AND LastName = 'Adams' B) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE FirstName = 'Gregory' AND LastName = 'Adams' C) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE Name = 'Gregory Adams' D) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462'

A) UPDATE Customer Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE FirstName = 'Gregory' AND LastName = 'Adams'
B) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE FirstName = 'Gregory' AND LastName = 'Adams'
C) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462' WHERE Name = 'Gregory Adams'
D) UPDATE Customer SET Address = '1337 Parkway Ave', City = 'Pembrook', State = 'SD', Zip = '57462'
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
33
The following command will compile a Java program called TestDB:

A) java TestDB.class
B) java TestDB.java
C) javac TestDB.java
D) javac TestDB.class
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
34
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
35
Given the following two statements, what does the call to the next() method return?
ResultSet result = statement.executeQuery();
Result.next();

A) The next record in the result.
B) true or false.
C) The primary key.
D) The next column in the table.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
36
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
37
Based on the table below, the SQL statement that changes the last name of customer 3175 to Michael is _____________________.
Customer table
<strong>Based on the table below, the SQL statement that changes the last name of customer 3175 to Michael is _____________________. Customer table  </strong> A) UPDATE Customer SET LastName = 'Michael' WHERE Customer_Number = 3175 B) UPDATE Customer SET Customer_Number = 3175 WHERE LastName = 'Michael' C) UPDATE Customer table SET LastName = 'Michael' WHERE Customer_Number = 3175 D) UPDATE Customer SET FirstName = 'Susan' WHERE LastName = 'Michael'

A) UPDATE Customer SET LastName = 'Michael' WHERE Customer_Number = 3175
B) UPDATE Customer SET Customer_Number = 3175 WHERE LastName = 'Michael'
C) UPDATE Customer table SET LastName = 'Michael' WHERE Customer_Number = 3175
D) UPDATE Customer SET FirstName = 'Susan' WHERE LastName = 'Michael'
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
38
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.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
39
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
40
Which SQL command(s) modify the data in a database?
I SELECT
II INSERT
III DELETE
IV UPDATE

A) I, II, III
B) II, III
C) II, III, IV
D) III, IV
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
41
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
42
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
43
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
44
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
45
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
46
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
47
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
48
What is the effect of the following statement?
String product_code = 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 the product_code.
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
49
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
50
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
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
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
53
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
54
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
55
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.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
56
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
57
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
58
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
59
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
60
A ______ lets you fetch a query result, one row at a time.

A) Query
B) Statement
C) ResultSet
D) PreparedStatement
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
61
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
62
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
63
To fetch a column in a result set that stores the number of children, 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
64
Beginners are afraid of issuing complex SQL queries, so they are ______

A) throwing away a major benefit of a relational database.
B) throwing an exception called badQueryException.
C) doing the right thing by avoiding those queries for efficiency.
D) taking advantage of the SQL benefits.
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
65
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
66
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
67
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
68
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
69
Database tables store rows that contain the following except

A) strings
B) fundamental data types
C) arbitrary objects
D) numbers
Unlock Deck
Unlock for access to all 75 flashcards in this deck.
Unlock Deck
k this deck
70
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
71
"SQL injection attacks" have been responsible for many cases of data theft. One of the solutions 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
72
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 start with 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
73
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
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
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
locked card icon
Unlock Deck
Unlock for access to all 75 flashcards in this deck.