Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 75

Given:

Which change would make Foo more secure?

    Correct Answer: B

    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
Adel2023Option: B

must be a static final variable

ASPushkinOption: B

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

d7bb0b2Option: D

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.

[Removed]Option: B

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.

StavokOption: C

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.