ANSWERS | HIGH-YIELD PRACTICE QUESTIONS | COMPLETE
EXAM PREP STUDY GUIDE | VERIFIED ANSWERS | LATEST
UPDATE
1. What does the os.R_OK constant represent in the context of the os.access
function in Python?
Delete permission
Read permission
Execute permission
Write permission
2. Assume x and y are String variables with x = "Hello" and y = null. The result of
(x = = y) is
a syntax error
x being set to the value null
false
true
a run-time error
3. What does the 403 Forbidden status code imply?
The client's request is malformed.
The client does not have the necessary permissions to access the
requested resource.
The server refuses to authorize the request.
The requested resource is temporarily unavailable.
,4. Describe how input validation helps in defending against log injection
attacks.
Input validation ensures that only properly formatted data is
accepted, preventing malicious input from being logged.
Input validation is used only for user authentication.
Input validation allows all data but filters it after logging.
Input validation is irrelevant to log security.
5. If a web application is vulnerable to session hijacking, what defensive coding
technique could be implemented to mitigate this risk?
Using only client-side validation for user inputs.
Disabling logging to prevent information leakage.
Allowing unrestricted access to API endpoints.
Implementing secure session management practices.
6. Describe the significance of returning the old value in the safe_deserialize
function when the keys match.
Returning the old value prevents data loss and maintains
consistency in the deserialization process.
Returning the old value allows for easier debugging of the function.
Returning the old value indicates a successful operation.
Returning the old value is irrelevant to the function's purpose.
7. You call a secured API with an expired token. What HTTP status code should
you expect?
404 Not Found
, 401 Unauthorized
400 Bad Request
403 Forbidden
8. Which HTTP response status code indicates that the user is not authenticated
to access the site?
404
400
401
403
201
9. What is the primary purpose of cross-origin resource sharing (CORS)?
To enable file sharing between different web applications.
To restrict web applications from accessing external resources.
To enhance the security of web applications by blocking all cross-
origin requests.
To allow web applications to make requests to domains other than
their own.
10. If a Python program uses os.access(filename, os.W_OK) and returns False,
what should the programmer infer about the file?
The file does not exist.
The file is not writable by the program.
The file is readable by the program.
The file is executable by the program.
, 11. What is the primary purpose of the function check_null_string in
programming?
To concatenate two strings.
To check if a string is null.
To convert a string to uppercase.
To count the number of characters in a string.
12. If a web application is vulnerable to SQL injection, what defensive coding
technique should be implemented to mitigate this risk?
Disabling error messages
Using prepared statements
Implementing cross-site scripting protection
Increasing server response time
13. What is the meaning of the HTTP status code 405?
Bad Request
Internal Server Error
Method Not Allowed
Not Found
14. In a scenario where a user attempts to access a resource without proper
authorization, what defensive coding technique could be implemented to
handle this situation effectively?
Implement input validation and return an appropriate HTTP status
code.
Display a message indicating the resource is unavailable.