Which of the following segments is a proper way to call the method readData four times? Group of answer choices int i = 0; while (i < 4) { readData(); i = i + 1; } double k = 0.0; while (k != 4) { readData(); k = k + 1; } int i = 0; while (i <= 4) { readData(); i = i + 1; } int i = 0; while (i < 4) { readData(); }

Respuesta :

Answer:

int i = 0; while (i < 4) { readData(); i = i + 1; }

Step-by-step explanation:

the above method is proper way to call the method readData four times because it will start from zero and will call readData until i=3, if i=4 it will stop calling readData.

double k = 0.0; while (k != 4) { readData(); k = k + 1; }

This is not the proper way to call readData four times because it will call readData only if k!=4 otherwise condition k!=4 will not be true and readData will not be called.

int i = 0; while (i <= 4) { readData(); i = i + 1; }

This is not the proper way to call readData four times because condition i<=4 will call readData five times starting from zero to 4.

int i = 0; while (i < 4) { readData(); }

This is not the proper way to call readData four times because it will call readData only one time i.e. value of is not incremented.