What is wrong with the following function:
public static void funMethod()
{
int i=100;
while (i < 10)
{
System.out.println("i="+i);
i++;
}
}
Select one:
a. loop control variable not declared
b. loop control variable is never updated
c. loop control variable not initialized
d. loop control variable never resolves to true
e. nothing is wrong with this code.
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
The answer to the first program is
d. loop control variable never resolves to true
int i = 100; //loop control variable is initialized and declared here
while(i < 10) //loop control variable never resolves to true
i++; //loop control variable is updated here
The answer to the second program is
a. nothing is wrong with this code.
int i = 1; //loop control variable is initialized and declared here
while(i < 10) //loop control variable resolves to true here
i++; //loop control variable is updated here
Get Answers For Free
Most questions answered within 1 hours.