About Question enthuware.ocpjp.v8.2.1405 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
ja3ekja
Posts: 2
Joined: Fri Nov 04, 2016 5:27 am
Contact:

About Question enthuware.ocpjp.v8.2.1405 :

Post by ja3ekja »

Hej,
Question 49, Test 2, a) option said
File f = new File("x");   //1 will throw an exception at runtime if a file named "x" does not exist.
answer is:
You can always create a File object whether or not an actual file or directory by that name exists.
I have just create:
File f = new File("C:\\example.txt"); I do not have this on my disc and I receive exception.
Do you agree with me that it is mistake in this test?
The next option in test is also good but If I have to choose one I choose this.
Please help me.

admin
Site Admin
Posts: 10385
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1405 :

Post by admin »

No, the explanation is correct. Please post exact and complete code that you have tried and the output that you have received.

thank you,
Paul.

runnerdave
Posts: 12
Joined: Mon Jan 30, 2017 2:58 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1405 :

Post by runnerdave »

Hi I copied and compiled the question and I receive the following compilation error:

TestClass.java:9: error: no suitable constructor found for PrintWriter(FileReader)
PrintWriter pw = new PrintWriter(new FileReader(f)); //4
^
constructor PrintWriter.PrintWriter(Writer) is not applicable
(argument mismatch; FileReader cannot be converted to Writer)
constructor PrintWriter.PrintWriter(OutputStream) is not applicable
(argument mismatch; FileReader cannot be converted to OutputStream)
constructor PrintWriter.PrintWriter(String) is not applicable
(argument mismatch; FileReader cannot be converted to String)
constructor PrintWriter.PrintWriter(File) is not applicable
(argument mismatch; FileReader cannot be converted to File)

admin
Site Admin
Posts: 10385
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1405 :

Post by admin »

Yes, that is expected. That is why option 3 and 4 are incorrect. Explanation to option 3 says the same thing.
Paul.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 16 guests