Given:
java
List
List
Collections.copy(l1, l2);
l2.set(0, "d");
System.out.println(l1);
What is the output of the given code fragment?
Given:
java
var deque = new ArrayDeque<>();
deque.add(1);
deque.add(2);
deque.add(3);
deque.add(4);
deque.add(5);
System.out.print(deque.peek() + " ");
System.out.print(deque.poll() + " ");
System.out.print(deque.pop() + " ");
System.out.print(deque.element() + " ");
What is printed?
Given:
java
public class ExceptionPropagation {
public static void main(String[] args) {
try {
thrower();
System.out.print("Dom Pérignon, ");
} catch (Exception e) {
System.out.print("Chablis, ");
} finally {
System.out.print("Saint-Émilion");
}
}
static int thrower() {
try {
int i = 0;
return i / i;
} catch (NumberFormatException e) {
System.out.print("Rosé");
return -1;
} finally {
System.out.print("Beaujolais Nouveau, ");
}
}
}
What is printed?
Given:
java
Period p = Period.between(
LocalDate.of(2023, Month.MAY, 4),
LocalDate.of(2024, Month.MAY, 4));
System.out.println(p);
Duration d = Duration.between(
LocalDate.of(2023, Month.MAY, 4),
LocalDate.of(2024, Month.MAY, 4));
System.out.println(d);
What is the output?
Given:
java
StringBuffer us = new StringBuffer("US");
StringBuffer uk = new StringBuffer("UK");
Stream
String output = stream.collect(Collectors.joining("-", "=", ""));
System.out.println(output);
What is the given code fragment's output?
A module com.eiffeltower.shop with the related sources in the src directory.
That module requires com.eiffeltower.membership, available in a JAR located in the lib directory.
What is the command to compile the module com.eiffeltower.shop?
Given:
java
List
integers.stream()
.peek(System.out::print)
.limit(2)
.forEach(i -> {});
What is the output of the given code fragment?
Given:
java
var frenchCities = new TreeSet
frenchCities.add("Paris");
frenchCities.add("Marseille");
frenchCities.add("Lyon");
frenchCities.add("Lille");
frenchCities.add("Toulouse");
System.out.println(frenchCities.headSet("Marseille"));
What will be printed?
You are working on a module named perfumery.shop that depends on another module named perfumery.provider.
The perfumery.shop module should also make its package perfumery.shop.eaudeparfum available to other modules.
Which of the following is the correct file to declare the perfumery.shop module?
Given:
java
double amount = 42_000.00;
NumberFormat format = NumberFormat.getCompactNumberInstance(Locale.FRANCE, NumberFormat.Style.SHORT);
System.out.println(format.format(amount));
What is the output?
What does the following code print?
java
import java.util.stream.Stream;
public class StreamReduce {
public static void main(String[] args) {
Stream
System.out.print(stream.reduce(String::concat));
}
}
Given:
java
Stream
BinaryOperator
String result = strings.reduce("-", operator);
System.out.println(result);
What is the output of this code fragment?
Given:
java
try (FileOutputStream fos = new FileOutputStream("t.tmp");
ObjectOutputStream oos = new ObjectOutputStream(fos)) {
fos.write("Today");
fos.writeObject("Today");
oos.write("Today");
oos.writeObject("Today");
} catch (Exception ex) {
// handle exception
}
Which statement compiles?
How would you create a ConcurrentHashMap configured to allow a maximum of 10 concurrent writer threads and an initial capacity of 42?
Which of the following options meets this requirement?
Given:
java
List
frenchAuthors.add("Victor Hugo");
frenchAuthors.add("Gustave Flaubert");
Which compiles?
Consider the following methods to load an implementation of MyService using ServiceLoader. Which of the methods are correct? (Choose all that apply)
Given:
java
List
.boxed()
.toList();
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
cannesFestivalfeatureFilms.stream()
.limit(25)
.forEach(film -> executor.submit(() -> {
System.out.println(film);
}));
}
What is printed?
Which of the following statements oflocal variables declared with varareinvalid?(Choose 4)