Oracle Java SE 21 Developer Professional - 1z0-830 模擬練習

Which of the following suggestions compile?(Choose two.)

正解: B,D
解説: (PassTest メンバーにのみ表示されます)
Which of the followingisn'ta correct way to write a string to a file?

正解: F
解説: (PassTest メンバーにのみ表示されます)
Which of the following isn't a valid option of the jdeps command?

正解: F
解説: (PassTest メンバーにのみ表示されます)
Given:
java
Stream<String> strings = Stream.of("United", "States");
BinaryOperator<String> operator = (s1, s2) -> s1.concat(s2.toUpperCase()); String result = strings.reduce("-", operator); System.out.println(result); What is the output of this code fragment?

正解: A
解説: (PassTest メンバーにのみ表示されます)
Given:
java
public class BoomBoom implements AutoCloseable {
public static void main(String[] args) {
try (BoomBoom boomBoom = new BoomBoom()) {
System.out.print("bim ");
throw new Exception();
} catch (Exception e) {
System.out.print("boom ");
}
}
@Override
public void close() throws Exception {
System.out.print("bam ");
throw new RuntimeException();
}
}
What is printed?

正解: C
解説: (PassTest メンバーにのみ表示されます)
Given:
java
String textBlock = """
j \
a \t
v \s
a \
""";
System.out.println(textBlock.length());
What is the output?

正解: C
解説: (PassTest メンバーにのみ表示されます)
Given:
java
DoubleSummaryStatistics stats1 = new DoubleSummaryStatistics();
stats1.accept(4.5);
stats1.accept(6.0);
DoubleSummaryStatistics stats2 = new DoubleSummaryStatistics();
stats2.accept(3.0);
stats2.accept(8.5);
stats1.combine(stats2);
System.out.println("Sum: " + stats1.getSum() + ", Max: " + stats1.getMax() + ", Avg: " + stats1.getAverage()); What is printed?

正解: C
解説: (PassTest メンバーにのみ表示されます)
Which two of the following aren't the correct ways to create a Stream?

正解: A,F
Given:
java
record WithInstanceField(String foo, int bar) {
double fuz;
}
record WithStaticField(String foo, int bar) {
static double wiz;
}
record ExtendingClass(String foo) extends Exception {}
record ImplementingInterface(String foo) implements Cloneable {}
Which records compile? (Select 2)

正解: A,D
解説: (PassTest メンバーにのみ表示されます)