SCJP刷题笔记(Part twelve)

QUESTION 111
Given:
SCJP刷题笔记(Part twelve)
and the command:
java Product 0
What is the result?
A. An AssertionError is thrown.
B. A compilation error occurs at line n1.
C. New Price: 0.0
D. A NumberFormatException is thrown at run time.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 112
Given the code fragment:
SCJP刷题笔记(Part twelve)
Assume that the value of now is 6:30 in the morning.
What is the result?
A. An exception is thrown at run time.
B. 0
C. 60
D. 1
Correct Answer: C
Section: (none)
ExplanationExplanation/Reference:
 
 
 
QUESTION 113
Given the code fragments:
SCJP刷题笔记(Part twelve)
and
SCJP刷题笔记(Part twelve)
What is the result?
A. The program prints Run… and throws an exception.
B. A compilation error occurs at line n1.
C. Run…
Call…
D. A compilation error occurs at line n2.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 114
Which two are elements of a singleton class? (Choose two.)
A. a transient reference to point to the single instance
B. a public method to instantiate the single instance
C. a public static method to return a copy of the singleton reference
D. a private constructor to the class
E. a public reference to point to the single instance
Correct Answer: BD
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 115
Given the code fragment:
SCJP刷题笔记(Part twelve)
What is the result?
A. David
David
[Susan, Allen]
B. Susan
Susan
[Susan, Allen]
C. Susan
Allen
[David]
D. David
Allen
[Susan]
E. Susan
Allen
[Susan, David]
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
SCJP刷题笔记(Part twelve)
 
 
 
QUESTION 116
Given:
SCJP刷题笔记(Part twelve)
and the code fragment:
SCJP刷题笔记(Part twelve)
Which two code fragments, when inserted at line n1 independently, enable the code to print
TruckCarBike?
A. .sorted ((v1, v2) -> v1.getVId() < v2.getVId())
B. .sorted (Comparable.comparing (Vehicle: :getVName)).reversed ()
C. .map (v -> v.getVid())
.sorted ()
D. .sorted((v1, v2) -> Integer.compare(v1.getVId(), v2.getVid()))
E. .sorted(Comparator.comparing ((Vehicle v) -> v.getVId()))
Correct Answer: DE
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 117
Given the code fragment:
SCJP刷题笔记(Part twelve)
What is the result?
A. A compilation error occurs at line n2.
B. 3
C. 2
D. A compilation error occurs at line n1.Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 118
Given the code fragment:
SCJP刷题笔记(Part twelve)
What is the result?
A. A compilation error occurs at line n1.
B. Logged out at: 2015-01-12T21:58:19.880Z
C. Can’t logout
D. Logged out at: 2015-01-12T21:58:00Z
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 119
Given the code fragment:
SCJP刷题笔记(Part twelve)
What is the result?
A. A compilation error occurs at line n1.
B. Checking…
C. Checking…Checking…
D. A compilation error occurs at line n2.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
 
 
 
QUESTION 120
Assume customers.txt is accessible and contains multiple lines.
Which code fragment prints the contents of the customers.txt file?
A. Stream<String> stream = Files.find (Paths.get (“customers.txt”));
stream.forEach((String c) -> System.out.println(c));
B. Stream<Path> stream = Files.find (Paths.get (“customers.txt”));
stream.forEach( c) -> System.out.println(c));
C. Stream<Path> stream = Files.list (Paths.get (“customers.txt”));
stream.forEach( c) -> System.out.println(c));
D. Stream<String> lines = Files.lines (Paths.get (“customers.txt”));
lines.forEach( c) -> System.out.println(c));
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference: