下列关于Test类的定义中,正确的是( )。A.class Test implements Runnable{ public void run{} Dublic void someMethod[]{} }B.class Test implements Runnable( puIblic void run; }C.class Test implements Runnable( Dublic void someMethod[]; }D.class Test implements Runnable( publi

题目

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

A.class Test implements Runnable{ public void run{} Dublic void someMethod[]{} }

B.class Test implements Runnable( puIblic void run; }

C.class Test implements Runnable( Dublic void someMethod[]; }

D.class Test implements Runnable( public void someMethod{} }


相似考题
更多“下列关于Test类的定义中,正确的是( )。 A.class Test implements Runnable{ public void run{} D ”相关问题
  • 第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;}; //④ private: int a; static int b; const int C; }; int Test::b=0; 在标注号码的行中,能被正确编译的是( )。

    A.①

    B.②

    C.③

    D.④


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

  • 第3题:

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

    A.

    B.

    C.

    D.


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

  • 第4题:

    如果使用Thread t=new Test()语句创建一个线程,则下列叙述正确的是

    A.Test类一定要实现Runnable接口

    B.Test类一定是Thread类的子类

    C.Test类一定是Runnable的子类

    D.Test类一定是继承Thread类并且实现Runnable接口


    正确答案:B
    解析:本题考查线程的使用。Java中可以通过实现Runnable接口来创建线程。通过这种方式创建线程是把Runnable的一个对象作为参数传递给Thread类的一个构造方法,该对象提供线程体run()。如果题目中Test实现Runnable接口,则创建线程的方法是Thread t=new Thread(new Test())。Java中另一种创建线程的方法是通过继承 Thread类,重写其中的run()方法定义线程体,然后直接创建该子类的对象即可创建线程。题目中使用Thread t=new Test()语句创建线程,其中直接创建Test类对象,可知该类一定是继承Thread类。因此,本题的正确答案是选项B。

  • 第5题:

    有如下类定义: 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。

  • 第6题:

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

    A..test{color:red;}

    B.#test{color:red;}

    C.test{color:red;}

    D.,test{color:red;}


    A