最新的Oracle Java SE 21 Developer Professional - 1z1-830免費考試真題

問題1
Given:
java
var now = LocalDate.now();
var format1 = new DateTimeFormatter(ISO_WEEK_DATE);
var format2 = DateTimeFormatter.ISO_WEEK_DATE;
var format3 = new DateFormat(WEEK_OF_YEAR_FIELD);
var format4 = DateFormat.getDateInstance(WEEK_OF_YEAR_FIELD);
System.out.println(now.format(REPLACE_HERE));
Which variable prints 2025-W01-2 (present-day is 12/31/2024)?

正確答案: C
說明:(僅 VCESoft 成員可見)
問題2
Given:
java
var lyrics = """
Quand il me prend dans ses bras
Qu'il me parle tout bas
Je vois la vie en rose
""";
for ( int i = 0, int j = 3; i < j; i++ ) {
System.out.println( lyrics.lines()
.toList()
.get( i ) );
}
What is printed?

正確答案: D
說明:(僅 VCESoft 成員可見)
問題3
Given:
java
package com.vv;
import java.time.LocalDate;
public class FetchService {
public static void main(String[] args) throws Exception {
FetchService service = new FetchService();
String ack = service.fetch();
LocalDate date = service.fetch();
System.out.println(ack + " the " + date.toString());
}
public String fetch() {
return "ok";
}
public LocalDate fetch() {
return LocalDate.now();
}
}
What will be the output?

正確答案: D
說明:(僅 VCESoft 成員可見)
問題4
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)

正確答案: B,C
說明:(僅 VCESoft 成員可見)
問題5
Given:
java
var sList = new CopyOnWriteArrayList<Customer>();
Which of the following statements is correct?

正確答案: C
說明:(僅 VCESoft 成員可見)
問題6
Given:
java
Runnable task1 = () -> System.out.println("Executing Task-1");
Callable<String> task2 = () -> {
System.out.println("Executing Task-2");
return "Task-2 Finish.";
};
ExecutorService execService = Executors.newCachedThreadPool();
// INSERT CODE HERE
execService.awaitTermination(3, TimeUnit.SECONDS);
execService.shutdownNow();
Which of the following statements, inserted in the code above, printsboth:
"Executing Task-2" and "Executing Task-1"?

正確答案: E,F
說明:(僅 VCESoft 成員可見)
問題7
Which of the following methods of java.util.function.Predicate aredefault methods?

正確答案: B,D,F
說明:(僅 VCESoft 成員可見)
問題8
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?

正確答案: C
說明:(僅 VCESoft 成員可見)
問題9
Given:
java
public static void main(String[] args) {
try {
throw new IOException();
} catch (IOException e) {
throw new RuntimeException();
} finally {
throw new ArithmeticException();
}
}
What is the output?

正確答案: C
說明:(僅 VCESoft 成員可見)