What is wrong with the following function:
public static void funMethod()
{
int i=1;
while (i < 10)
{
System.out.println("i="+i);
i++;
}
}
Select one:
a. nothing is wrong with this code.
b. loop control variable not initialized
c. loop control variable is never updated
d. loop control variable not declared
e. loop control variable never resolves to true
Answer-------- option a Nothing is wrong with this code.
Explanation-----------
Here loop control variable which is i is intialized. int i=0 is call intialization so option B is wrong.
loop control variable, which is i is update everytime. i++ is there so that its update, so that option c is also wrong.
Loop control variable which is i is declared as int i. as int i=0 is nothing but declration and intialization simultanously. so that option d is also wrong.
loop control variable i updates its value in loop and always satisfy the condition in loop. It resolves true, so that option e is also wrong.
Therefore, all the options are wrong and option A is correct.
If you have any problem concern with given solution, then please feel free to ask in comment section, I will always there for you in any time, and dont forget to hit the like buttton, Thumbs up guys...
Get Answers For Free
Most questions answered within 1 hours.