Oracle Java SE 21 Developer Professional - 1z0-830 Exam Practice Test

Given:
java
public class SpecialAddition extends Addition implements Special {
public static void main(String[] args) {
System.out.println(new SpecialAddition().add());
}
int add() {
return --foo + bar--;
}
}
class Addition {
int foo = 1;
}
interface Special {
int bar = 1;
}
What is printed?
Correct Answer: D
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
Given:
java
LocalDate localDate = LocalDate.of(2020, 8, 8);
Date date = java.sql.Date.valueOf(localDate);
DateFormat formatter = new SimpleDateFormat(/* pattern */);
String output = formatter.format(date);
System.out.println(output);
It's known that the given code prints out "August 08".
Which of the following should be inserted as the pattern?
Correct Answer: D
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
Which three of the following are correct about the Java module system?
Correct Answer: B,D,F
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
Given:
java
int post = 5;
int pre = 5;
int postResult = post++ + 10;
int preResult = ++pre + 10;
System.out.println("postResult: " + postResult +
", preResult: " + preResult +
", Final value of post: " + post +
", Final value of pre: " + pre);
What is printed?
Correct Answer: D
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
Given:
java
void verifyNotNull(Object input) {
boolean enabled = false;
assert enabled = true;
assert enabled;
System.out.println(input.toString());
assert input != null;
}
When does the given method throw a NullPointerException?
Correct Answer: B
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
Which of the following can be the body of a lambda expression?
Correct Answer: A
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
Given:
java
StringBuilder result = Stream.of("a", "b")
.collect(
() -> new StringBuilder("c"),
StringBuilder::append,
(a, b) -> b.append(a)
);
System.out.println(result);
What is the output of the given code fragment?
Correct Answer: A
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
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?
Correct Answer: A
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
Given:
java
var hauteCouture = new String[]{ "Chanel", "Dior", "Louis Vuitton" };
var i = 0;
do {
System.out.print(hauteCouture[i] + " ");
} while (i++ > 0);
What is printed?
Correct Answer: B
Explanation: Only visible for TrainingDump members. You can sign-up / login (it's free).
0
0
0
0