niusouti.com

阅读下面代码:import java.awt.*;public class Exam11_1{private Frame. f;private Button b1,b2,b3,b4;public static void main(String args[]{Exam11_1 that = new Exam11 1 ();that.go();}public void go(){______;f.setLayout(new FlowLayout()) ;;b1 = new Button ("Button 1"

题目

阅读下面代码:

import java.awt.*;

public class Exam11_1

{

private Frame. f;

private Button b1,b2,b3,b4;

public static void main(String args[]

{

Exam11_1 that = new Exam11 1 ();

that.go();

}

public void go()

{

______;

f.setLayout(new FlowLayout()) ;;

b1 = new Button ("Button 1");

b2 = new Button ("Button 2");

b3 = new Button ("Button 3");

b4 = new Button ("Button 4");

f.add (b1);

f.add (b2);

f.add (b3);

f.add (b4);

f.pack ();

f.setVisible (true);

}

}

请在程序中画线处填写正确的语句【 】,以便编译运行程序后得到正确的结果。


相似考题
更多“阅读下面代码: import java.awt.*; public class Exam11_1 {private Frame. f;private Button b1 ”相关问题
  • 第1题:

    下面这个程序的结果是 include class A { private: int a; public: void seta( ) ;

    下面这个程序的结果是

    #include<iostream.h>

    class A

    {

    private:

    int a;

    public:

    void seta( ) ;int geta( ) ;};

    void A: :seta( )

    { a=1;}

    int A: :geta( )

    { retum a;}

    class B

    { private:

    int a;

    public:

    void seta( ) ;int geta( ) ;};

    void B: :seta( )

    {a=2;}

    int B: :geta( )

    {return a;}

    class C: public A,public B

    { private:

    int b;

    public:

    void display( ) ;};

    void C: :display( )

    { int b=geta( ) ;

    cout < < b;}

    void main( )

    { C c;

    c. seta( ) ;

    c. display( ) ;}

    A.1

    B.2

    C.随机输出1或2

    D.程序有错


    正确答案:D
    解析:在类A中有geta( ) 函数,在类B中也有geta( ) 函数,类C继承了类A和类B,这样就产生了二义性,所以程序会出错。

  • 第2题:

    阅读下面程序: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

  • 第3题:

    判断下面程序编译是否正确,如果错误简要说明原因 class B{ public: B(int a){ x=a; } private: int x; }; class D : public B{ public: D(int a ) : y(a){ } private: int y; };


    #define b 2 int x = b; void main() { x++; }

  • 第4题:

    下面程序的结果为includeint c;class A{private:int a;static int b;public:A( ){a

    下面程序的结果为 #include<iostream.h> int c; class A { private: int a; static int b; public: A( ) {a=0;c=0;} void seta( ){a++;} void setb( ){b++;}

    A.1 2 1

    B.1 2 2

    C.1 1 2

    D.2 2 2


    正确答案:B
    解析:C++语言中全局变量是任何函数都可以改变的量,静态变量的有效范围在定义它的类中,而普通的变量的有效性只在使用它的函数中,在本题中c为全局变量,b为静态变量,a为普通变量,b和c在类A的对象a1和a2中都自加1。所以b,c为 2,a为1。

  • 第5题:

    访问修饰符作用范围由大到小是( )

    A)private-default-protected-public

    B)public-default-protected-private

    C)private-protected-default-public

    D)public-protected-default-private


    答案:D

  • 第6题:

    访问修饰符作用范围由大到小是

    A.private-default-protected-public

    B.public-default-protected-private

    C.private-protected-default-public

    D.public-protected-default-private


    D