SCJP刷题笔记(Part sixteen)

QUESTION 151
Which two statements are true about the Fork/Join Framework? (Choose two.)
A. The RecursiveTask subclass is used when a task does not need to return a result.
B. The Fork/Join framework can help you take advantage of multicore hardware.
C. The Fork/Join framework implements a work-stealing algorithm.
D. The Fork/Join solution when run on multicore hardware always performs faster than standard sequential
solution.
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
Reference: https://www.logicbig.com/tutorials/core-java-tutorial/java-multi-threading/fork-and-join.html
 
 
 
QUESTION 152
Which two statements are true about synchronization and locks? (Choose two.)
A. A thread automatically acquires the intrinsic lock on a synchronized statement when executed.
B. The intrinsic lock will be retained by a thread if return from a synchronized method is caused by an
uncaught exception.
C. A thread exclusively owns the intrinsic lock of an object between the time it acquires the lock and the
time it releases it.
D. A thread automatically acquires the intrinsic lock on a synchronized method’s object when entering that
method.
E. Threads cannot acquire intrinsic locks on classes.
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
Reference: https://docs.oracle.com/javase/tutorial/essential/concurrency/locksync.html
 
 
 
QUESTION 153
Given the code fragment:
SCJP刷题笔记(Part sixteen)
Which should be inserted into line n1 to print Average = 2.5?
A. IntStream str = Stream.of (1, 2, 3, 4);
B. IntStream str = IntStream.of (1, 2, 3, 4);
C. DoubleStream str = Stream.of (1.0, 2.0, 3.0, 4.0);
D. Stream str = Stream.of (1, 2, 3, 4);
Correct Answer: C
Section: (none)
ExplanationExplanation/Reference:
 
 
 
QUESTION 154
Given the structure of the Student table:
SCJP刷题笔记(Part sixteen)
Student (id INTEGER, name VARCHAR)
Given the records from the STUDENT table:
Given the code fragment:
SCJP刷题笔记(Part sixteen)
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists.
What is the result?
A. The program prints Status: true and two records are deleted from the Student table.
B. The program prints Status: false and two records are deleted from the Student table.
C. A SQLException is thrown at runtime.
D. The program prints Status: false but the records from the Student table are not deleted.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 155
Given the code fragments:
SCJP刷题笔记(Part sixteen)
and
SCJP刷题笔记(Part sixteen)
What is the result?
A. Video played.Game played.
B. A compilation error occurs.
C. class java.lang.Exception
D. class java.io.IOException
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 156
What is true about the java.sql.Statement interface?
A. It provides a session with the database.
B. It is used to get an instance of a Connection object by using JDBC drivers.
C. It provides a cursor to fetch the resulting data.
D. It provides a class for executing SQL statements and returning the results.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Reference: https://docs.oracle.com/cd/E13222_01/wls/docs45/classdocs/java.sql.Statement.html
 
 
 
QUESTION 157
Given that data.txt and alldata.txt are accessible, and the code fragment:
SCJP刷题笔记(Part sixteen)
What is required at line n1 to enable the code to overwrite alldata.txt with data.txt?
A. br.close();
B. bw.writeln();
C. br.flush();
D. bw.flush();
Correct Answer: D
Section: (none)Explanation
Explanation/Reference:
 
 
 
QUESTION 158
Given:
SCJP刷题笔记(Part sixteen)
and the code fragment:
SCJP刷题笔记(Part sixteen)
What is the result?
A. [Java EE: Helen:Houston]
[Java ME: Jessy:Chicago, Java ME: Mark:Chicago]
B. Java EE
Java ME
C. [Java ME: Jessy:Chicago, Java ME: Mark:Chicago]
[Java EE: Helen:Houston]
D. A compilation error occurs.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
SCJP刷题笔记(Part sixteen)
 
 
 
QUESTION 159
Given:
SCJP刷题笔记(Part sixteen)
From what threading problem does the program suffer?
A. race condition
B. deadlock
C. starvation
D. livelock
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 160
Given the definition of the Employee class:
SCJP刷题笔记(Part sixteen)
and this code fragment:
SCJP刷题笔记(Part sixteen)
What is the result?
A. [sales:Ada, hr:Bob, sales:Bob, hr:Eva]
B. [Ada:sales, Bob:sales, Bob:hr, Eva:hr]
C. [hr:Eva, hr:Bob, sales:Bob, sales:Ada]
D. [hr:Bob, hr:Eva, sales:Ada, sales:Bob]
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference: