adplus-dvertising
frame-decoration

Question

What is the output of the below java program that implements nesting of loops?
int i=1, j=1;
while(i<3)
{
  do
  {
    System.out.print(j + ",");
    j++;
  }while(j<4);
  i++;
}

a.

1,2,3,4,1,2,3,4,

b.

1,2,3,4,

c.

1,2,3,1,2,3,

d.

1,2,3,

Posted under Java Programming

Answer: (b).1,2,3,4,

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the below java program that implements nesting of loops?