Assertions
Category: Assertions
Author: Benson Limketkai
Book Chapter: 5.5
Problem: Assertions
For each of the five points labeled by comments, identify each of the following assertions as being either always true, never true or sometimes true / sometimes false. public static int mystery(int a) { int b = 1; <span class="assertionpoint">// Point A while(a > 0) { <span class="assertionpoint">// Point B b += a; if(b > a) { <span class="assertionpoint">// Point C b = -b; } <span class="assertionpoint">// Point D a--; } <span class="assertionpoint">// Point E return b; }
1) a < b
2) a > 0
3) b > 0