Question: A software security expert reviews the following Java code based on best practices and provides the following answer. Is it True or False? Exercise 1

A software security expert reviews the following Java code based on best practices and provides the following answer. Is it True or False?
Exercise 1. Given the below Java method, are there any (syntactical, semantical, logical) errors? What can be improved from the security-compliance perspective? If there are security-related issues, how can we fix them?
```
class MyClass {
private int a = l;
private void doLogic()(
int a; //...
}
}
```
Answer.
This security-noncompliant code example reuses the name of the yal instance field in the scope of an instance method.
The resulting behavior can be classified as shadowing; the method variable renders the class variable inaccessible within the scope of the method.
Example: assigning to this.val from within the method does not affect the value of the class variable.
class MyVector \{
private int yal =\(\underline{\underline{1}}\);
private void doLogic)\{
int newValue;
//...
\}
\}
This security-compliant solution eliminates shadowing by changing the name of the variable defined in the method scope from yal to newValue.
A software security expert reviews the following

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!