Oracle Java SE 21 Developer Professional Sample Questions:
1. Given:
java
public class Test {
public static void main(String[] args) throws IOException {
Path p1 = Path.of("f1.txt");
Path p2 = Path.of("f2.txt");
Files.move(p1, p2);
Files.delete(p1);
}
}
In which case does the given program throw an exception?
A) An exception is always thrown
B) Both files f1.txt and f2.txt exist
C) File f1.txt exists while file f2.txt doesn't
D) Neither files f1.txt nor f2.txt exist
E) File f2.txt exists while file f1.txt doesn't
2. Given:
java
Object input = 42;
String result = switch (input) {
case String s -> "It's a string with value: " + s;
case Double d -> "It's a double with value: " + d;
case Integer i -> "It's an integer with value: " + i;
};
System.out.println(result);
What is printed?
A) It's a double with value: 42
B) It throws an exception at runtime.
C) It's a string with value: 42
D) It's an integer with value: 42
E) null
F) Compilation fails.
3. 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?
A) Sum: 22.0, Max: 8.5, Avg: 5.0
B) Sum: 22.0, Max: 8.5, Avg: 5.5
C) An exception is thrown at runtime.
D) Compilation fails.
4. Which of the following doesnotexist?
A) DoubleSupplier
B) BiSupplier<T, U, R>
C) LongSupplier
D) They all exist.
E) BooleanSupplier
F) Supplier<T>
5. Given:
java
interface Calculable {
long calculate(int i);
}
public class Test {
public static void main(String[] args) {
Calculable c1 = i -> i + 1; // Line 1
Calculable c2 = i -> Long.valueOf(i); // Line 2
Calculable c3 = i -> { throw new ArithmeticException(); }; // Line 3
}
}
Which lines fail to compile?
A) Line 3 only
B) Line 1 only
C) Line 1 and line 3
D) The program successfully compiles
E) Line 2 and line 3
F) Line 2 only
G) Line 1 and line 2
Solutions:
| Question # 1 Answer: A | Question # 2 Answer: F | Question # 3 Answer: B | Question # 4 Answer: B | Question # 5 Answer: D |


PDF Version Demo






We are confident about the products and aim to help you pass with ease. In case of failure, we will provide a no hassle full money back guarantee for the purchasing fee.
832 Customer Reviews
Quality and ValueITbraindumps Practice Exams are written to the highest standards of technical accuracy, using only certified subject matter experts and published authors for development - no all study materials.
Tested and ApprovedWe are committed to the process of vendor and third party approvals. We believe professionals and executives alike deserve the confidence of quality coverage these authorizations provide.
Easy to PassIf you prepare for the exams using our ITbraindumps testing engine, It is easy to succeed for all certifications in the first attempt. You don't have to deal with all dumps or any free torrent / rapidshare all stuff.
Try Before BuyITbraindumps offers free demo of each product. You can check out the interface, question quality and usability of our practice exams before you decide to buy.