Java Reference
In-Depth Information
3.
What does the
Class.forName(
String
)
method accomplish?
a.
It provides the name of a class.
b.
It loads a database driver that can be used to access a database.
c.
It deletes an object.
Answers
1. b.
The class, part of the
java.sql
package, represents an SQL statement.
2. b.
Because it is compiled,
PreparedStatement
is a better choice when you're
going to execute the same SQL query numerous times.
3. b.
This static method loads a database driver.
Certification Practice
The following question is the kind of thing you could expect to be asked on a Java pro-
gramming certification test. Answer it without looking at today's material or using the
Java compiler to test the code.
Given:
18
public class ArrayClass {
public static ArrayClass newInstance() {
count++;
return new ArrayClass();
}
public static void main(String arguments[]) {
new ArrayClass();
}
int count = -1;
}
Which line in this program prevents it from compiling successfully?
a.
count++;
b.
return new ArrayClass();
c.
public static void main(String arguments[]) {
d.
int count = -1;