COding
COding
3. Inconsistent synchronization
Deadlock is a situation in which one or more
threads mutually lock each other.
Array Index Out of Bounds:
Array index often goes out of bounds, leading to
exceptions. Care need to be taken to see that the array
index values are not negative and do not exceed their
bounds.
Arithmetic exceptions:
These include errors like divide by zero and
floating point exceptions. The result of these may
vary from getting unexpected results to termination
of the program.
Off by One:
This is one of the most common errors which can be
caused in many ways. For example, starting at 1 when
we should start at 0 or vice versa, writing <=N instead of
< N or vice versa, and so on.
Enumerated data types:
Overflow and underflow errors can easily occur when
working with enumerated types, and care should be
taken when assuming the values of enumerated data
types.
Illegal use of & instead of &&:
This bug arises if non short circuit logic (like & or |) is
used instead of short circuit logic (&& or ||). Non short
circuit logic will evaluate both sides of the expression.
But short circuit operator evaluates one side and based
on the result, it decides if it has to evaluate the other
side or not.