New Year Sale ! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Oracle Exam 1Z0-829 Topic 4 Question 8 Discussion

Actual exam question for Oracle's 1Z0-829 exam
Question #: 8
Topic #: 4
[All 1Z0-829 Questions]

Assuming that the data, txt file exists and has the following content:

Text1

Text2

Text3

Given the code fragment:

What is the result?

Show Suggested Answer Hide Answer
Suggested Answer: D

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.Reference:

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


Contribute your Thoughts:

Currently there are no comments in this discussion, be the first to comment!


Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77