1z0-819 Exam QuestionsBrowse all questions from this exam

1z0-819 Exam - Question 75


Given:

Which change would make Foo more secure?

Show Answer
Correct Answer: B,C

The change that would make the Foo class more secure is making ALPHA a public static final String. This ensures that the value of ALPHA cannot be altered after its initial assignment, providing immutability and protecting it from external modifications. This is particularly important for static variables, as they are shared across all instances of the class. Final ensures that the variable is fixed and secure.

Discussion

5 comments
Sign in to comment
Adel2023Option: B
May 23, 2023

must be a static final variable

StavokOption: C
Jul 17, 2023

The change that would make the Foo class more secure is option C. private String delta. This would restrict access to the delta variable to only within the Foo class, making it more secure.

[Removed]Option: B
Sep 27, 2023

In the original code it is possible to set the ALPHA-static variable before calling the foo()-method by Foo.ALPHA = "xxxx"; To make it more secure you should make this variable final so that an outside program cannot modify it.

d7bb0b2Option: D
Dec 10, 2023

The correct answer is D. protected final String beta = "beta"; Making the beta field final would prevent it from being modified after it is initialized, which can make the class more secure by ensuring that the beta field cannot be changed after the object is constructed. Changing the access modifier to protected would restrict access to the beta field to classes in the same package and subclasses, which can also improve security by limiting the code that can access the field.

ASPushkinOption: B
Jul 15, 2024

answer: B make more secure because of final attribute C failed it can be changed without final attribute D failed the value can be changed A failed make less secure because of public access