SCJP刷题笔记(Part fifteen)
QUESTION 141
Given:
What is the result?
A. Hi Interface-2
B. A compilation error occurs.
C. Hi Interface-1
D. Hi MyClass
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 142
Given:
and the code fragment:
Which definition of the ColorSorter class sorts the blocks list?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 143
Given the code fragment:
Which two code fragments, when inserted at line n1 independently, result in the output PEEK: Unix?
A. .anyMatch ();
B. .allMatch ();
C. .findAny ();
D. .noneMatch ();
E. .findFirst ();
Correct Answer: CE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 144
Given the code fragments:
and
Which two modifications enable to sort the elements of the emps list? (Choose two.)
A. Replace line n1 with
class Person extends Comparator<Person>
B. At line n2 insert
public int compareTo (Person p) {
return this.name.compareTo (p.name);
}
C. Replace line n1 with
class Person implements Comparable<Person>
D. At line n2 insert
public int compare (Person p1, Person p2) {
return p1.name.compareTo (p2.name);
}
E. At line n2 insert:
public int compareTo (Person p, Person p2) {
return p1.name.compareTo (p2.name);
}
F. Replace line n1 with
class Person implements Comparator<Person>
Correct Answer: BC
Section: (none)
Explanation
Explanation/Reference:
QUESTION 145
Given:
and the code fragment:
What is the result?
A. 0.0
B. 1500.0
C. A compilation error occurs.
D. 2000.0
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 146
Given the code fragment:
Assume that dbURL, userName, and password are valid.
Which code fragment can be inserted at line n1 to enable the code to print Connection
Established?A. Properties prop = new Properties();
prop.put (“user”, userName);
prop.put (“password”, password);
con = DriverManager.getConnection (dbURL, prop);
B. con = DriverManager.getConnection (userName, password, dbURL);
C. Properties prop = new Properties();
prop.put (“userid”, userName);
prop.put (“password”, password);
prop.put(“url”, dbURL);
con = DriverManager.getConnection (prop);
D. con = DriverManager.getConnection (dbURL);
con.setClientInfo (“user”, userName);
con.setClientInfo (“password”, password);
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 147
Given the Greetings.properties file, containing:
and given:
What is the result?
A. Compilation fails.
B. GOODBY_MSG
C. Hello, everyone!
D. Goodbye everyone!
E. HELLO_MSG
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 148
Given the code fragments:
and
What is the result?
A. null
B. A compilation error occurs.
C. DogCatMouse
D. [Dog, Cat, Mouse]
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 149
Given the records from the STUDENT table:
Given the code fragment:
Assume that the URL, username, and password are valid.
What is the result?
A. The STUDENT table is not updated and the program prints:
114 : John : [email protected]
B. The STUDENT table is updated with the record:
113 : Jannet : [email protected]
and the program prints:
114 : John : [email protected]
C. The STUDENT table is updated with the record:
113 : Jannet : [email protected]
and the program prints:
113 : Jannet : [email protected]
D. A SQLException is thrown at run time.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 150
Given the code fragment:
Which code fragment, when inserted at line 7, enables printing 100?
A. Function<Integer> funRef = e –> e + 10;
Integer result = funRef.apply(value);
B. IntFunction funRef = e –> e + 10;
Integer result = funRef.apply (10);
C. ToIntFunction<Integer> funRef = e –> e + 10;
int result = funRef.applyAsInt (value);
D. ToIntFunction funRef = e –> e + 10;
int result = funRef.apply (value);
Correct Answer: ASection: (none)
Explanation
Explanation/Reference: