Exam Name: | Java SE 21 Developer Professional | ||
Exam Code: | 1z0-830 Dumps | ||
Vendor: | Oracle | Certification: | Java SE |
Questions: | 84 Q&A's | Shared By: | layan |
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
Optional
String bread = optionalName.orElse("Baguette");
System.out.print("bread:" + bread);
String dish = optionalName.orElseGet(() -> "Frog legs");
System.out.print(", dish:" + dish);
try {
String cheese = optionalName.orElseThrow(() -> new Exception());
System.out.println(", cheese:" + cheese);
} catch (Exception exc) {
System.out.println(", no cheese.");
}
What is printed?
Given:
java
List
frenchAuthors.add("Victor Hugo");
frenchAuthors.add("Gustave Flaubert");
Which compiles?