public class X { public X aMethod() { return this;} } public class Y extends X { } Which two methods can be added to the definition of class Y?()
第1题:
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
第2题:
有以下程序:
include<iostream>
using namespace std;
class Base
{
public:
Base()
{
K=0;
}
int x;
};
class Derivedl:virtual public Base
{
public:
Derivedl()
{
x=10;
}
};
class Derived2:virtua1 public Base
第3题:
有以下程序:
included<iostream>
using namespace std;
class Base
{
public:
Base( )
{
x=0;
}
int x;
};
class Derived1:virtual public Base
{
public:
Derived1( )
{
x=10;
}
};
class Derived2:virtual public Base
{
public:
Derived2( )
{
x=20;
}
};
class Derived: public Derived1,protected Derived2
{ };
int main( )
{
Derived obj;
cout<<obj. x<<endl;
return 0;
}
该程序运行后的输出结果是______。
第4题:
有如下程序: #include <iostream> using namespace std; Class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<
A.1
B.123
C.242
D.244
第5题:
在下列源代码文件Test.java中,正确定义类的代码是( )。
A.pblic 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.protected class Test extends T2{ public int x = 0; public Test(int x) { this. x = x; } }
第6题:
A.class x { .... }
B.public x extends y { .... }
C.public class x extends y { .... }
D.class x extends y implements y1 { .... }
第7题:
若有以下程序: #include <iostream> using namespace std; class Base { public: Base ( ) { x=0; } int x; }; class Derivedl : virtual public Base { public: Derivedl () { x=10; } }; class Derived2 : virtual public Base { public: Derived2 () { x=20; } }; class Derived : public Derivedl,protected Derived2{ }; int main ( ) { Derived obj; cout<<obj .x<<end1; return 0; } 该程序运行后的输出结果是 ( )。
A.20
B.30
C.10
D.0
第8题:
下列哪个方法可用于创建一个可运行的类? ( )
A.public class X implements Runable {public void run(){...,.,}}
B.public class X implements Thread {public void run(){......}}
C.public class X implements Thread {public int run(){……}}
D.public class X implements Runable {protected void run(){.....}}
第9题:
有以下程序:
include<iostream.h>
class A
{
int x;
public:
A(int a)
{
x=a;
}
friend class B;
}
class B{
public:
void print(A a){
a. x--;
cout<<a.x<<end1;
}
};
void main()
{
A a(10);
B b;
b.print(a) ;
}
程序执行后的输出结果是【 】。
第10题:
若有以下程序: #include <iostream> using namespace std; class Base public: Base() { x=0; } int x; }; class Derivedl: virtual public Base public: Derived1() { x=10; } }; class Derived2: virtual public Base publici Derived2() x=20; }; class Derived :public Derived1,protected Derived2 {}; int main() Derived obj; cout<<obj.x<<end1; return 0; } 该程序运行后的输出结果是
A.20
B.30
C.10
D.0