1z0-829: Java SE 17 Developer Fragment Practice Questions
The free 1z0-829: Java SE 17 Developer questions that deal with fragment, with answers and explanations. The full bank and the timed practice test cover every topic the exam asks about.
Question #3
Assuming that the data, txt file exists and has the following content: Text1 Text2 Text3 Given the code fragment: What is the result?

Correct answer: C
Explanation
The answer is D because the code fragment reads the file ??data.txt?? and collects all the lines in the file into a single string, separated by hyphens. Then, it prints the resulting string. Next, it attempts to read the fourth line in the file (index 3) and print it. However, since the file only has three lines, an IndexOutOfBoundsException is thrown. References: • Oracle Certified Professional: Java SE 17 Developer • Java SE 17 Developer • OCP Oracle Certified Professional Java SE 17 Developer Study Guide • Read contents of a file using Files class in Java
Question #7
Given the course table: Given the code fragment:


Correct answer: A
Explanation
The code fragment will execute the update statement and set the course fee of the course with ID 1021 to 5000. The executeUpdate method returns an int value that indicates the number of rows affected by the SQL statement. In this case, only one row will be updated, so the result variable will be 1. The if statement will check if the result is greater than 0, which is true, and print ??Updated successfully??. Therefore, the output of the code fragment is true. References: https://education.oracle.com/products/trackp_OCPJSE17, https://mylearn.oracle.com/ou/learning-path/java-se-17-developer/99487, https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/Statement.html#execut eUpdate(java.lang.String)
Question #9
Given the code fragment: What is the result?

Correct answer: D
Explanation
The code fragment is using the switch statement with the new Java 17 syntax. The switch statement checks the value of the variable rank and executes the corresponding case statement. In this case, the value of rank is 4, so the first case statement is executed, printing ??Range1??. The second and third case statements are also executed, printing ??Range2?? and ??Range3??. The default case statement is also executed, printing ??Not a valid rank??. References: Java Language Changes - Oracle Help Center
Continue with 1z0-829: Java SE 17 Developer
Unlock the full question bank
You have read the first 10 questions. A subscription opens every question in 1z0-829: Java SE 17 Developer, the full timed practice test, and your progress and weak-topic reporting.
Single exam
$19.99for 30 days
Full question bank and practice test for one exam, for 30 days.
Single exam
$49.99for 1 year
One exam for a full year. Nothing renews and nothing to cancel.
Full access
$39.99/mo
Every exam in the catalogue, month to month.
Full access
$199.99/yr
Every exam in the catalogue for a year.
Already subscribed? Sign in to pick up where you left off.
