About Question enthuware.ocpjp.v11.2.3415 :

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

Moderator: admin

Post Reply
powerofviva
Posts: 8
Joined: Tue Sep 19, 2023 12:11 pm
Contact:

About Question enthuware.ocpjp.v11.2.3415 :

Post by powerofviva »

But the user did not validate the input right?
so number 2 is also correct? isnt it?

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

Re: About Question enthuware.ocpjp.v11.2.3415 :

Post by admin »

There is nothing to validate in the input. The input is a file name and if the file name is incorrect, there will be an exception as indicated by the throws clause.
The real issue in the code is opening unlimited number of files.
If you like our products and services, please help us by posting your review here.

powerofviva
Posts: 8
Joined: Tue Sep 19, 2023 12:11 pm
Contact:

Re: About Question enthuware.ocpjp.v11.2.3415 :

Post by powerofviva »

Ok got it now,
thanks

adrianjara
Posts: 2
Joined: Fri May 03, 2024 6:41 am
Contact:

Re: About Question enthuware.ocpjp.v11.2.3415 :

Post by adrianjara »

About this code:

Code: Select all

public void processUploads(String listOfFilesFile) throws IOException{
    File f = new File(listOfFilesFile);

The name of the argument refers to the fact that the entry is a list, that is, it contains several file names separated by commas.

Is that to confuse? How do we know that only the name of a file arrives there?

Then, there is no File constructor that receives several file names separated by commas, which is why the input would have to be previously validated to verify the type of value in the argument that arrives,

That's why my answer would also be No. 2.

The security part is very broad and extensive, but the answers to why one or the other is selected is not clear.

Could you expand the explanation further?

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

Re: About Question enthuware.ocpjp.v11.2.3415 :

Post by admin »

The name listOfFilesFile ends with 'File', so it is quite clear that it will get a String containing the name of the file that contains a list of files. Also, the parameter type is just String and not List<String>.
Further, File f = new File(listOfFilesFile); clearly implies that listOfFilesFile is a path to a file.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

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