下列关于Test类的定义中,正确的是( )。
A.
B.
C.
D.
第1题:
阅读下面程序
class Test implements Runnable{
public static void main(String[] args){
Test t = new Test();
t.start();
}
public void run(){ }
}
下列关于上述程序的叙述正确的是
A) 程序不能通过编译,因为 start() 方法在 Test 类中没有定义
B) 程序编译通过,但运行时出错,提示 start() 方法没有定义
C) 程序不能通过编译,因为 run() 方法没有定义方法体
D) 程序编译通过,且运行正常
第2题:
下列关于Java源程序结构的论述中,正确的是______。
A) 一个文件包含的import语句最多1个
B) 一个文件包含的public类最多1个
C) 一个文件包含的接口定义最多1个
D) 一个文件包含的类定义最多1个
A.
B.
C.
D.
第3题:
下列关于类定义的说法中,正确的是
A.类定义中包括数据成员和函数成员的声明
B.类成员的缺省访问权限是保护的
C.数据成员必须被声明为私有的
D.成员函数只能在类体外进行定义
第4题:
A.public class test { public int x = 0; public test(int x) { this.x = x; } }
B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }
C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }
D.public class
第5题:
应在下面程序下划线中填写的正确的语句是( )。 #include <iostream> using namespace std; class A{ public: void test(){cout<< "this is A!";} }; class B:public A{ void test(){ ______ //显示调用基类函数test() cout<< "this is B!"; } }; void main(){}
A.A::test()
B.test()
C.B::test()
D.this->test()
第6题:
阅读下面程序 class Test implements Runnable { public static void main(String[] args) { Test t=new Test(); t.start(): } public void run() {} } 下列关于上述程序的叙述正确的是
A.程序不能通过编译,因为start()方法在Test类中没有定义
B.程序编译通过,但运行时出错,提示start()方法没有定义
C.程序不能通过编译,因为run()方法没有定义方法体
D.程序编译通过,且运行正常
第7题:
有如下类定义: 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.④
第8题:
下列关于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{} }
第9题:
有如下类定义: class Test { int x_,y_; public: Test ():a_(0) ,b_(0) {} Test(int a,int b=0) :a_(a),b_(b){} }; 若执行语句 Test x(2) ,y[3],*z[4]; 则Test类的构造函数被调用的次数是( )。
A.2次
B.3次
C.4次
D.5次
第10题:
在下列源代码文件Test.java中, ( )是正确的类定义。
A.public class test{
B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }
C.public class Test extends T1,T2{
D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}
第11题:
下列选项中,能正确定义数组的语句是( )。
A.
B.
C.
D.
第12题:
下列关于类层次中静态成员的描述,正确的是()
第13题:
如果使用 Thread t = new Test() 语句创建一个线程,则下列叙述正确的是
A)Test 类一定要实现 Runnable 接口
B)Test 类一定是 Thread 类的子类
C)Test 类一定是 Runnable 的子类
D)Test 类一定是继承 Thread 类并且实现 Runnable 接口
第14题:
下列关于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.
第15题:
下列关于私有继承的说法中正确的是()。
A、基类成员对派生类新定义的成员函数是不可见的;
B、基类成员对派生类新定义的成员函数是可见的;
C、只有基类成员中的公有成员对派生类新定义的成员函数是可见的;
D、基类成员中的保护成员对派生类新定义的成员函数是可见的。
第16题:
在如下结构定义中,不正确的是()。
A.
B.
C.
D.
第17题:
已知有下列类的说明,则下列( )语句是正确的。 publicClass Test{ private float f=1.0f; int m=12; static int n=1: public static void main(Stringarg[]){ Test t=new Test(): } }
A.t.f;
B.this.n;
C.Test.m;
D.Test.f;
第18题:
如果使用Thread t=new Test()语句创建一个线程,则下列叙述正确的是
A.Test类一定要实现Runnable接口
B.Test类一定是Thread类的子类
C.Test类一定是Runnable的子类
D.Test类一定是继承Thread类并且实现Runnable接口
第19题:
A.
B.
C.
D.
第20题:
有如下类定义: class Test { public: Test{a=0;c=0;}//① int f(im A.const{this->a=a;}//② static int g{return a;f//③ void h(int B.{Test:.b=b;};//④ private: int a; static int b; const int C; }; int Test::b=0: 在标注号码的行中,能被正确编译的是( )。
A.①
B.②
C.③
D.④
第21题:
以下关于子类和父类的叙述中,正确的是______。
A.代码中使用父类对象的地方,都可以使用子类对象替换
B.代码中使用子类对象的地方,都可以使用父类对象替换
C.父类定义的对象与子类定义的对象在属性和方法上一定相同
D.父类定义的对象与子类定义的对象在属性和方法上一定不同
A.
B.
C.
D.
第22题:
关于下面程序,( )的结论是正确的。
classJ_SubClassextendsJ_Test{}
publicclassJ_Test{
J_Test(inti){
System.out.println(i);
}
publicstaticvoidmain(String[]args){
J_SubClassa=newJ_SubClass();
}
}
A、不能通过编译,因为类J_Test没有定义无参数的构造方法
B、不能通过编译,因为类J_SubClass没有定义无参数的构造方法
C、不能通过编译,因为没有实现J_SubClass(inti)的构造方法
D、可以成功通过编译
第23题:
在下列源代码文件Test.java中,哪个选项是正确的类定义? ( )
A.public class test { public int x=0; public test(int x) { this.x=x; } }
B.public class Test { public int x=0; public Test(int x) { this.x=x; } }
C.public class Test extends Ti,T2 { public int x=0; public Test(int x) { this.x=x; } }
D.protected class Test extends T2 { public int x=0; public Test(int x) { this.x=x; } }