Email address:
Password:
SCJP/OCPJP 1.6 certification
Practice Exams and Training
SCJP Online Training » Discussions

Am I supposed to know about openOption[] ?

BufferedWriter br = Files.newBufferedWriter(myPath,Charset.forName("UTF-8"),new OpenOption[]{StandardOpenOption.APPEND, StandardOpenOption.DSYNC});


It is not mentioned in the certification objectives. I read that I should know how to identify the successful combinations.

As you are preparing for OCPJP 7, yes, OpenOption is in the exam even though it is not explicitly mentioned in the objectives.

Given a set of options, we have to identify the correct combinations.


1. new OpenOption[]{StandardOpenOption.WRITE, StandardOpenOption.DELETE_ON_CLOSE}

2. new OpenOption[]{StandardOpenOption.READ, StandardOpenOption.DELETE_ON_CLOSE}

3. new OpenOption[]{StandardOpenOption.DELETE_ON_CLOSE, StandardOpenOption.TRUNCATE_EXISTING}

4. new OpenOption[]{StandardOpenOption.APPEND, StandardOpenOption.CREATE_NEW}

5. new OpenOption[]{StandardOpenOption.READ, StandardOpenOption.SYNC}


How do I solve such questions?

When you have a question from API contents, you should be able to figure it from JSR or the basic documentation of the API. However, in this particular case, the JSR doesn't say anything, and documentation of Files.newBufferedWriter doesn't say anything about it either (Check: Java7 , Java8).


In other words, the which OpenOptions should be compatible with each other is not documented as at this moment. When there is a thing that is undocumented, the JRE vendor has the liberty to customize it in the whatever they want, and you would expect to see different results on different JRE implementations.


I do know that the exam may contain questions about OpenOptions, but I don't think you would get questions like this in the exam. However, I'm not heavily familiar with how the questions in the version 7 of the exam are designed, so I can't be sure.

ExamLab © 2008 - 2024