下列关于Test类的定义中,正确的是______。A) class Test implements Runnabte{public void run(){}public void someMethod(){}B) class Test implements Rnuuable{public void run();}C) class Test implements Rnuuable{public void someMethod();}D) class Test implements Rnuuable{publ

题目

下列关于Test类的定义中,正确的是______。

A) class Test implements Runnabte{

public void run(){}

public void someMethod(){}

B) class Test implements Rnuuable{

public void run();

}

C) class Test implements Rnuuable{

public void someMethod();

}

D) class Test implements Rnuuable{

public void someMethod();{}

}

A.

B.

C.

D.


相似考题
更多“下列关于Test类的定义中,正确的是______。A) class Test implements Runnabte{ public void run() ”相关问题
  • 第1题:

    下列程序的运行结果是______。 include class test { private: int hum; public: tes

    下列程序的运行结果是______。

    include<iostream.h>

    class test

    {

    private:

    int hum;

    public:

    test( );

    int TEST( ){return num+100;)

    ~test( );

    };

    test::test( ){num=0;)

    test::~test( ){cout<<"Destructor is active"<<endl;)

    void main( )

    {

    test x[3];

    cout<<x[1].TEST( )<<endl;

    }


    正确答案:100 Destructor is active Destructor is active Destructor is active
    100 Destructor is active Destructor is active Destructor is active 解析:本题比较简单,考查考生基本的类的定义,构造函数以及对象数组的概念。

  • 第2题:

    有如下类定义: class Test { public: Test(){a=0;c=0;} //① int f(int a)const {this->a=a;} //② static int g(){return a;} //③ void h(int b){Test::b=b;}; //④ private: int a; static int b; const int c; }; int Test::b=0; 在标注号码的行中,能被正确编译的是

    A.①

    B.②

    C.③

    D.④


    正确答案:D
    解析:本题考查了类的定义。一个类的常数据成员的初始化只能在成员初始化列表中进行,所以选项A不正确。常成员函数不能更新对象的数据成员,所以选项B不正确。静态成员函数可以直接访问类中说明的静态成员,但不能直接访问类中说明的非静态成员,所以选项C也不正确。故应该选择D。

  • 第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题:

    有如下类定义: class Test { public: Test(){a=0;c=0} //① int f(int a)const{this->a=a;} //② static int g(){return a;} //③ void h(int b){Test::b;}; //④ private: int a; static int b; const int C; }; int Test::b=0; 在标注号码的行中,能被正确编译的是( )。

    A.①

    B.②

    C.③

    D.④


    正确答案:D
    解析:此题考查的是类的定义。一个类的长数据成员的初始化只能在成员初始化列表中进行,故选项A) 错误;常成员函数不能更新对象的数据成员,故选项B) 错误;静态成员函数可以直接访问类中说明的静态成员,但不能直接访问类中说明的非静态成员,故选项C) 错误。

  • 第5题:

    下列关于Test类的定义中,正确的是( )。

    A.

    B.

    C.

    D.


    正确答案:A
    java中实现多线程的方法之-就是实现Runnable接口中的run方法,把实现Runnable接口的子类对象传递给Thread类的构造函数。

  • 第6题:

    【单选题】定义了类选择器test,让段落应用class名为test的类,下列写法正确的是:

    A..test{color:red;}

    B.#test{color:red;}

    C.test{color:red;}

    D.,test{color:red;}


    A