Question: Consider the following methods. / * * Precondition: a > 0 and b > 0 * / publ ic stat ic int methodOne ( int

Consider the following methods.
/** Precondition: a >0 and b >0*/
publ ic stat ic int methodOne( int a, int b)
{
int loopCount =0;
for ( int i =0; i < a / b; i++)
{
loopCount++;
}
return loopCount ;
}
/** Precondition: a >0 and b >0*/
publ ic stat ic int methodTwo( int a, int b)
{
int loopCount =0;
int i =0;
whi le ( i < a)
{
loopCount++;
i += b;
}
return loopCount ;
}
Which of the following best describes the conditions under which methodOne and methodTwo return
the same value?
(A) When a and b are both even
(B) When a and b are both odd
(C) When a is even and b is odd
(D) When a % b is equal to zero
(E) When a % b is equal to one

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!