Question: Hi Could you please explain my why is this answer in Java? nt var1 = 0; int var2 = 2; while ((var2 != 0) &&

Hi Could you please explain my why is this answer in Java?

nt var1 = 0; int var2 = 2; while ((var2 != 0) && ((var1 / var2) >= 0)) { var1 = var1 + 1; var2 = var2 -1; } 

(A) var1 = 1, var2 = 1 (B) var1 = 2, var2 = 0

Answer: var1 = 2, var2 = 0

private int[ ] a = {1, 3, -5, -2}; public void multAll(int amt) { int i = 0; while (i < a.length) { a[i] = a[i] * amt; i++; } // end while } // end method 

(B) {3, 9, -15, -6}

private int[ ] a = {1, 3, -5, -2}; public void mult(int amt) { int i = 0; while (i < a.length) { a[i] = a[i] * amt; } // end while } // end method 

(D) The code will never stop executing due to an infinite loop

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 Databases Questions!