WHAT WOULD BE PRINTED FROM EACH OF THE FOLLOWING PROGRAM SEG


WHAT WOULD BE PRINTED FROM EACH OF THE FOLLOWING PROGRAM SEGM int j = 10 while (++j

Solution

The output is

14

18

explanation:

executing 1st time

while (++j<=16)//j=11
{
j++;//j=12
j=j+1;//j=13
system.out.println(++j); // j=14 gets printed
}

2nd time when loop is executed

while (++j<=16)//j=15
{
j++;//j=16
j=j+1;//j=17
system.out.println(++j); // j=18 gets printed
}

3rd time the while condition becomes false

 WHAT WOULD BE PRINTED FROM EACH OF THE FOLLOWING PROGRAM SEGM int j = 10 while (++j SolutionThe output is 14 18 explanation: executing 1st time while (++j<=

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site