niusouti.com

阅读下面程序import javax.swing.JOptionPane;public class BreakLabelTest{public static void main (String args[]){String utput=" ";stop:{for(int row=1;row<10;row++){for(int column=1;column<=5;column++){if(row=5)break stop;output+=" * ";}output+=" \n ";}output+="\n

题目

阅读下面程序

import javax.swing.JOptionPane;

public class BreakLabelTest{

public static void main (String args[]){

String utput=" ";

stop:{

for(int row=1;row<10;row++){

for(int column=1;column<=5;column++){

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行* * * * *


相似考题
更多“阅读下面程序 import javax.swing.JOptionPane; public class BreakLabelTest{public static voi ”相关问题
  • 第1题:

    下面程序的结果是includeclass A{int a;public:A( ):a(1){}void showa( ){cout<

    下面程序的结果是 #include<iostream.h> class A { int a; public: A( ):a(1){} void showa( ){cout<<a;} }; class B { int a; public: B( ) :a(2) {}

    A.1

    B.2

    C.3

    D.程序有错误


    正确答案:C
    解析:类A,类B,中都有showa()函数,类C继承后再次重写showa()函数就解决了继承的二义性,这时c.showa()函数显示的就是类C中的showa()的值。

  • 第2题:

    下面程序的输出结果是()。include using namespace std;class A {public:A( ) {cout<<

    下面程序的输出结果是( )。 #include <iostream> using namespace std; class A { public: A( ) {cout<<"A";} } class B { public: B() {coat<<"B" ;} } class C: public A { public: B b; C() {cout<<"C";} } void mian(){ C c; }

    A.CBA

    B.ABC

    C.ACB

    D.BCA


    正确答案:B
    解析:先执行基类A构造函数输出A,调用类B的构造函数输出B,调用本身构造函数输出C。

  • 第3题:

    阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。
    【说明】
    以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。




    【Java代码】
    interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}


    答案:
    解析:
    (1)void drawCircle (int radius,int x,int y)
    (2)DrawCircle drawCircle
    (3)super.drawcircle=drawcircle
    (4)drawCircle(radius,x,y)
    (5)new RedCircle()
    (6)new GreenCircle()【解析】
    第一空是填接口里面的方法,在接口的实现里面找,可以发现应该填void drawCircle (int radius,int x,int y)。
    第二空可以根据后面this drawCircle=drawCircle判断,这里应该有一个drawCircle属性,因此应该填)DrawCircle drawCircle。
    第三空这里用super,用super. drawcircle来引用父类的成员。
    第四空调用drawCircle(radius,x,y)方法。
    第五、六空分别创建一个红色圆形对象和一个绿色圆形对象作为Circle里面的实参。

  • 第4题:

    阅读下面程序:include template class TAdd{private:T x, y;public:TAdd(T

    阅读下面程序:

    include <iostream.h>

    template <class T>

    class TAdd

    {

    private:

    T x, y;

    public:

    TAdd(T a, T b)

    {

    x=a;

    y=b;

    }

    T add()

    {

    return x +y;

    }

    };

    void main( )

    {

    TAdd<int>a(5,6);

    TAdd<double>b(2.4,5.8);

    cout<<"s1 ="<<A. add()<<",";

    cout<<"s2="<<B, add()<<end1;

    }

    写出该程序的运行结果:【 】。


    正确答案:s1=11s2=8.2
    s1=11,s2=8.2

  • 第5题:

    下面程序的结果是 ______。includeclass A{ public:virtual voidfun()=0{};};class

    下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }

    A.new file open file save file

    B.new file new file new file

    C.编译出错

    D.open file new file save file


    正确答案:C

  • 第6题:

    阅读下面的程序, 写出运行后输出的结果。 #include<iostream> using namespace std; class A { public: A(){cout<<"A";} }; class B :public A { public: B(){cout<<"B";} }; void main() { B b1; }


    baCBAcd