阅读下面程序
import javax.swing.JOptionPane;
public class BreakLabelTest
public static void main(String args[])
String output=" ":
stop:
for(int row=1;row<=10;row++)
for(int column=1;column<=5;colunm++)
if(row==5)break stop;
output+="*":
output+="\n";
output+="\nLoops terminated normally":
JOptionPane.showMessageDialog(null,output,"用一个标志测试break语句",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
程序运行的结果是
A.窗口中有5行*****
B.窗口中有5行****
C.窗口中有4行*****
D.窗口中有6行*****
参考答案:C
解析: 本程序的功能是向屏幕输出“*”。题目中用了一个两层嵌套的for循环。内层循环控制每行输出的“*”个数,从初值1到5共5个。外层循环控制行数,for的循环初值为1,终值为10,但是当row为5时,跳出了stop所指定的代码块。所以只执行了4行。