Free Oracle 1Z0-829 Exam Actual Questions

The questions for 1Z0-829 were last updated On Nov 18, 2024

Question No. 1

Given the code fragment:

What is the result:

Show Answer Hide Answer
Correct Answer: D

The answer is D because the code fragment uses the Stream API to create two streams, s1 and s2, and then concatenates them using the concat() method. The resulting stream is then processed in parallel using the parallel() method, and the distinct() method is used to remove duplicate elements. Finally, the forEach() method is used to print the elements of the resulting stream to the console. Since the order of elements in a parallel stream is unpredictable, the output could be any of the options given, but option D is the most likely.Reference:

Oracle Certified Professional: Java SE 17 Developer

Java SE 17 Developer

OCP Oracle Certified Professional Java SE 17 Developer Study Guide

Parallelizing Streams


Question No. 2

Given:

What is the result

Show Answer Hide Answer
Correct Answer: C

The code fragment is using the switch statement with the new Java 17 syntax. The switch statement checks the value of the variable desig and executes the corresponding case statement. In this case, the value of desig is ''CTO'', which does not match any of the case labels. Therefore, the default case statement is executed, which prints ''Undefined''. The other case statements are not executed, because there is no fall through in the new syntax. Therefore, the output of the code fragment is:

Undefined


Question No. 3

Given the code fragment:

What is the result?

Show Answer Hide Answer
Correct Answer: D

The answer is E because the code fragment creates a new Pet object with the name ''Dog'' and assigns it to the variable p. Then, it assigns p to p1. Next, it changes the name of p1 to ''Cat''. Then, it assigns p1 to p. Finally, it sets p to null and prints the name of p and p1. The output will be ''Cat'' and ''null'' because p is set to null and p1 still points to the Pet object with the name ''Cat''.


Question No. 4

Given the code fragment:

What is the result?

Show Answer Hide Answer
Correct Answer: C

The code fragment is creating a string variable ''a'' with the value ''Hello! Java''. Then, it is printing the index of ''Java'' in ''a''. Next, it is replacing ''Hello!'' with ''Welcome!'' in ''a''. Then, it is printing the index of ''Java'' in ''a''. Finally, it is creating a new StringBuilder object ''b'' with the value of ''a'' and printing the index of ''Java'' in ''b''. The output will be 8109 because the index of ''Java'' in ''a'' is 8, the index of ''Java'' in ''a'' after replacing ''Hello!'' with ''Welcome!'' is 10, and the index of ''Java'' in ''b'' is 9.Reference:Oracle Java SE 17 Developer source and documents: [String (Java SE 17 & JDK 17)], [StringBuilder (Java SE 17 & JDK 17)]