About Question enthuware.ocpjp.v11.2.3406 :

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

Moderator: admin

Post Reply
peterz
Posts: 6
Joined: Tue Jan 26, 2021 9:24 am
Contact:

About Question enthuware.ocpjp.v11.2.3406 :

Post by peterz »

I cannot get my head around these security questions...

If the analyzeBonds method would be written by our own company instead of in a third party library, would the answer still be that I should create a defensive copy?

Typically, I would not use a third party library that I would not trust, so I treat it like our own code in the end...

And what if my application never uses the prepared Bond[] after the analysis. Why should I create a copy?

For me, many of the security questions lack context which I would need to answer them. Any hints on how to address this in the exam?

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

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

Post by admin »

I agree with you on this. However, since the exam just tries to test you on the basic things, they just expect you to apply the principles given in the Security Coding Guidelines. Real life problems are not that straightforward and the solutions are not always so black and white.

So, it is best to just go through the guidelines and apply those for the purpose of the exam without worrying too much about alternative solutions.
If you like our products and services, please help us by posting your review here.

gadsgadsx
Posts: 14
Joined: Fri Apr 12, 2024 11:09 pm
Contact:

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

Post by gadsgadsx »

Since there's some cases where the objects doesnt need to be cloned (like Strings, Wrappers or LocalDateTime objects), I thought I shouldn't answser option C because I can't say anything about Bond class.

I don't know if my understanding is correct, but for immutable classes the clone approach is not a must, right? Since the objects are already immutable?

I also have a second question... since the argument passed to the analyzeBonds() method is an Array, does it make a difference if Bond is immutable? I mean, if it was a String[] (String itself is immutable), do I have to clone the String[] reference?

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

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

Post by admin »

1. Right, if an object is immutable, a defensive copy is not required.
2. Yes, arrays are mutable and so a defensive copy of the array is required.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests