Monday, August 24, 2015

While Loop in Different Forms

Predict the output of the following codes:

1. int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");

}


2.   int i=110;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


3.  int i=0;
while(i<10);
{
JOptionPane.showMessageDialog(rootPane,"hello");
i=i+1;
}


4.   int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i++;
}


5.  int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i--;
}


6.  int i=0;
while(i==10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


7.  while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


8.  int i=0;
while(i<10)
{
JOptionPane.showMessage Dialog(rootPane. "hello");
}


9. int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i=10;
}


10. int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i=i+1;
i=i-1;
}

11.

while(1)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


No comments: