Q1. Which two statements are true for a two-dimensional array of primitive data type?
A. It cannot contain elements of different types.
B. The length of each dimension must be the same.
C. At the declaration time, the number of elements of the array in each dimension must be specified.
D. All methods of the class object may be invoked on the two-dimensional array.
Answer: C,D
Explanation: http://stackoverflow.com/questions/12806739/is-an-array-a-primitive-type-or-an-object-or-something-else-entirely
Q2. Given:
What is the result?
A. 2 4 6 8
B. 2 4 6 8 9
C. 1 3 5 7
D. 1 3 5 7 9
Answer: D
Q3. Given the fragments:
Which line causes a compilation error?
A. Line n1
B. Line n2
C. Line n3
D. Line n4
Answer: A
Q4. Given:
What is the result?
A. Null
B. Compilation fails
C. An exception is thrown at runtime
D. 0
Answer: C
Q5. Given the code fragment:
What is the result?
A. Found Red Found Default
B. Found Teal
C. Found Red Found Blue Found Teal
D. Found Red Found Blue Found Teal Found Default
E. Found Default
Answer: B
Q6. Given:
Item table
. ID, INTEGER: PK
. DESCRIP, VARCHAR(100)
. PRICE, REAL
. QUANTITY< INTEGER
And given the code fragment:
9. try {
10.Connection conn = DriveManager.getConnection(dbURL, username, password);
11.
String query = “Select * FROM Item WHERE ID = 110”;
12.
Statement stmt = conn.createStatement();
13.
ResultSet rs = stmt.executeQuery(query);
14.while(rs.next()) {
15.System.out.println(“ID:“ + rs.getInt(“Id”));
16.System.out.println(“Description:“ + rs.getString(“Descrip”));
17.System.out.println(“Price:“ + rs.getDouble(“Price”));
18. System.out.println(Quantity:“ + rs.getInt(“Quantity”));
19.}
20.
} catch (SQLException se) {
21.
System.out.println(“Error”);
22.
}
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists.
The SQL query is valid.
What is the result?
A. An exception is thrown at runtime.
B. Compilation fails.
C. The code prints Error.
D. The code prints information about Item 110.
Answer: C