From the course: Java SE 21 Developer (1Z0-830) Cert Prep

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Question deep dive

Question deep dive

- Let's look at a question. So given infile.dat is readable, what's the result of this code? Well, the first option suggests that the code at line n1 is not valid syntax for obtaining a channel. Well, hopefully you recognize that getChannel invoked on a FileInputStream is in fact valid, because it's a FileInputStream the channel will be open and readable. We wouldn't be able to write to that channel, but we're not trying to, so that turns out to be solid. So option A is incorrect. Option B says that things will fail at line n2, here, on the basis that the arguments to this open method are incorrect. Well, again, with luck you'll recall that the file channel open takes a path and then at least one of its forms takes a series, a comma separated list, of standard open options. So it is not an incorrect syntax in that case. So option B is also incorrect. Option C suggests that execution fails because the options that…

Contents