Which one of the following bugs can be caught by Static Analysis?

The following requirement is given “Set X to be the sum of Y and Z”.

All the following four implementations have bugs.

Which one of the following bugs can be caught by Static Analysis?
A . int x = 1. int y = 2. int y = 3. X = y=z;
B . int x = 1. int y = 2. int z = 3. X = z-y
C . int x = 1. Int y = 2. Int z = 3. Z = x +y
D . int y = 2 Int z = 3. Y = z+y

Answer: A

Explanation:

Static analysis is a technique that analyzes the source code or other software artifacts without executing them. Static analysis can detect defects such as syntax errors, coding standards violations, potential security vulnerabilities, or logical flaws. Static analysis can catch the bug in the first implementation, as it contains two syntax errors: the variable y is declared twice, and the assignment statement X = y=z is invalid. Static analysis cannot catch the bugs in the other three implementations, as they are logical errors that do not violate any syntax rules, but produce incorrect results.

Reference: [A Study Guide to the ISTQB® Foundation Level 2018 Syllabus – Springer], Chapter 3, page 25-26.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments