class ClassA {}  class ClassB extends ClassA {}  class ClassC extends ClassA {}  and:  ClassA p0 = new ClassA();  ClassB p1 = new ClassB();  ClassC p2 = new ClassC();  ClassA p3 = new ClassB();  ClassA p4 = new ClassC();  Which three are valid?()A、 p0 = p1;B、 p1 =p2;C、 p2 = p4;D、 p2 = (ClassC)p1;E、 p1 = (ClassB)p3;F、 p2 = (ClassC)p4;

class ClassA {}  class ClassB extends ClassA {}  class ClassC extends ClassA {}  and:  ClassA p0 = new ClassA();  ClassB p1 = new ClassB();  ClassC p2 = new ClassC();  ClassA p3 = new ClassB();  ClassA p4 = new ClassC();  Which three are valid?()

  • A、 p0 = p1;
  • B、 p1 =p2;
  • C、 p2 = p4;
  • D、 p2 = (ClassC)p1;
  • E、 p1 = (ClassB)p3;
  • F、 p2 = (ClassC)p4;

相关考题:

下列程序段中,A_class的成员函数Variance()可求出两数的平方差,请改写该程序段,把Variance()函数从A_class类中分离出来,用友元函数来实现该函数的功能。class A_class {private:intx,y,t;public:A_class(int i,int j):x(i),y(j) {if(yx){t=x;x=y;y=t;}}intVariance(){return x*x-y*y;}//其它函数从略};void main() {A_classA_obj(3,5);coutResult:A_obj.Variance()endl;}

在下面程序的横线处填上适当的语句,使程序执行后的输出结果为ABCD。 include using nam 在下面程序的横线处填上适当的语句,使程序执行后的输出结果为ABCD。include<iostream>using namespace std;classA{public:A(){cout<<'A';}};class B:______{public:B(){cout<<'B';}};class C:______{public:C(){cout<<'C';}};class D:public B,public C{public:D(){cout<<'D';}};void main(){D obj;)

有如下程序:includeusing namespace std;classA{public:virtua1 voidfunc1(){cout 有如下程序: #include<iostream> using namespace std; classA{ public: virtua1 voidfunc1(){cout<<“A1”;} voidfunc2(){cout<<“A2”;}}; class B:publicA{ public: void funcl(){cout<<“B1”;} void func2(){cout<<“B2”;}}; intmain(){ A*p=neA.B1B2B.A1A2C.B1A2D.A1B2

Whatproducesacompilererror?() A.classA{publicA(intx){}}B.classA{}classBextendsA{B(){}}C.classA{A(){}}classB{publicB(){}}D.classZ{publicZ(int){}}classAextendsZ{}

InwhichtwocasesdoesthecompilersupplyadefaultconstructorforclassA?() A.classA{}B.classA{publicA(){}}C.classA{publicA(intx){}}D.classZ{}classAextendsZ{voidA(){}}

有如下程序:includeusing namespace std;classA{public:A(){cout 有如下程序: #include<iostream> using namespace std; classA { public: A(){cout<<"A";} }; class B{public:B(){cout<<"B";}}; class C:public A { B b; public: C(){cout<<"C";} }; int main(){C obj;return 0;} 执行后的输出结果是( )A.ABCB.BACC.ACBD.CBA

有以下程序:includeusing namespace std;classA{private: int x;public: A(int a) {x 有以下程序: #include<iostream> using namespace std; class A { private: int x; public: A(int a) { x=a; } friend class B; }; class B { public: void print(A a) { a.x--; cout<<a, x<<end1; } }; int main () { A a(10); B b; b.print (a) ; return 0; } 程序执行后的输出结果是( )。A.9B.10C.11D.12

下面程序输出的结果为 #include"iostream.h" class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASSB"<<endl;} ~B() {} }; void main() { A * p; p=new B; B *q; q=new B; }A.CLASS A CLASS BB.CLASS A CLASS B CLASS BC.CLASS A CLASS B CLASS A CLASS BD.CLASS A CLASS B CLASS B CLASS B

下面程序段的输出结果为( )。 package test; public class ClassA { int x=20: static int y=6; public static void main(String args[]) { ClassB b=new ClassB; go(10); System.out.println("x="+b.x); } } class ClassB { int X; void go(int y) { ClassA a=new ClassA; x=a.Y ; } }A.x=10B.x=20C.x=6D.编译不通过

下面程序输出的结果为( )。 #include"iostream.h" classA {public: A(){cOUt"CLASSA"endl;} ~A(){}}; ClaSSB:publicA {public: B(){cout"CLASSB"endl;} ~B(){}}; voidmain() {A*P; P=newB: B*q: q=newB;}A.CLASSAB.CLASSA CLASSBCLASSB CLASSBC.CLASSAD.CLASSA CLASSBCLASSB CLASSACLASSB CLASSBCLASSB

下面程序输出的结果为 #include"iostream.h” class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASS B"<<endl;} ~B(){} }; void main() { A*p; p=new B;A.CLASS A CLASS B CLASS B CLASS BB.CLASS A CLASS B CLASS A CLASS BC.CLASS A CLASS B CLASS BD.CLASS A CLASS B

设有以下定义和程序:includeclassA1{public:void show1(){ cout 设有以下定义和程序: #include<iostream.h> classA1 { public: void show1() { cout<<"classA1”<<end1; } }; classA2:public A1 { public: void show2() { cout<<"classA2"<<end1; } }; class A3:protected A2 { public: voidshow3() { cout<<"class A1”<<end1; } }; void main() { A1obj1; A2obj2; A3obj3; } 则以下不合语法的调用语句是A.obj1.show1();B.obj2.show1();C.obj3.show1();D.obj2.show2();

下面程序段的输出结果为 package test; public class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println(”x=”+b.x); } } class Class B { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x=20C.x=6D.编译不通过

有如下模板声明:templatetypenameT1,typenameT2classA;下列声明中,与上述声明不等价的是( )。A.templateclassTl,classT2classA;B.templateclassT1,typenameT2classAtC.templatetypenameT1,classT2classA;D.templatetypenameT1,T2classA;

有以下源程序: package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } } 上述源程序文件的运行结果为( )。A.x=10B.x=20C.x=6D.编译不通过

下面程序输出的结果为( )。 includeiostream.hclassA{public: A(){cOUtiostream.hclassA{public:A(){cOUtCLASSAendl;}~A(){}};ClaSSB:publicA{public:B(){coutCLASSBendl;}~B(){}};voidmain(){A*P;P=newB:B*q:q=newB;}A.CLASSBB.CLASSA CLASSB CLASSBC.CLASSA CLASSB CLASSA CLASSBD.CLASSA CLASSB CLASSB CLASSB

10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?() A、 StackOverflowErrorB、 NullPointerExceptionC、 NumberFormatExceptionD、 IllegalArgumentExceptionE、 ExceptionlnlnitializerError

GPRS服务类型有CLASS A、CLASS B、CLASS C三种:()在上网的时候会将电话功能屏蔽,当有电话进来的时候自动切断网络;()可以同时使用网络和电话功能;()则是单纯的网络应用, 不提供电话功能。A、CLASSB;CLASSA;CLASSCB、CLASSA;CLASSB;CLASSCC、CLASSC;CLASSB;CLASSAD、CLASSC;CLASSA;CLASSB

public class ClassA{ public int getValue(){ int value=0; boolean setting=true; String title="Hello"; if(value||(setting title=="Hello")){return 1;} if(value==1title.equals("Hello")){return 2;} } } And: ClassA a=new ClassA(); a.getValue(); What is the result?()A、1B、2C、Compilation fails.D、The code runs with no output.E、An exception is thrown at runtime.

Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()A、p0 = p1;B、p1 = p2;C、p2 = p4;D、p2 = (ClassC)p1;E、p1 = (ClassB)p3;F、p2 = (ClassC)p4;

单选题class ClassA {  public int numberOfinstances;  protected ClassA(int numberOfinstances) {  this.numberOflnstances = numberOfinstances;  }  }  public class ExtendedA extends ClassA {  private ExtendedA(int numberOfinstances) {  super(numberOflnstances);  }  public static void main(String[] args) {  ExtendedA ext = new ExtendedA(420);  System.out.print(ext.numberOflnstances);  }  }  Which is true?()A 420 is the output.B An exception is thrown at runtime.C All constructors must be declared public.D Constructors CANNOT use the private modifier.E Constructors CANNOT use the protected modifier.

问答题类ClassB从ClassA派生,那么ClassA*a=newClassB(…);试问该表达是否合法?为什么?

单选题10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?()A StackOverflowErrorB NullPointerExceptionC NumberFormatExceptionD IllegalArgumentExceptionE ExceptionlnlnitializerError

多选题Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()Ap0 = p1;Bp1 = p2;Cp2 = p4;Dp2 = (ClassC)p1;Ep1 = (ClassB)p3;Fp2 = (ClassC)p4;

多选题现有:  class ClassA  {}  class ClassB extends ClassA  {)      class ClassC extends ClassA  {)     以及:  ClassA p0=new ClassA();      ClassB pl=new ClassB();      ClassC p2=new ClassC();     ClassA p3=new ClassB();    ClassA p4=new ClassC(); 下列哪些是正确的?()Ap0=pl;Bp1 =p2;Cp2=p4;Dp2 = (ClassC)pl;Ep1 = (ClassB)p3;Fp2 =  (Classc)p4;

单选题public class ClassA{ public int getValue(){ int value=0; boolean setting=true; String title="Hello"; if(value||(setting title=="Hello")){return 1;} if(value==1title.equals("Hello")){return 2;} } } And: ClassA a=new ClassA(); a.getValue(); What is the result?()A1B2CCompilation fails.DThe code runs with no output.EAn exception is thrown at runtime.

单选题10. public class ClassA {  11. public void methodA() {  12. ClassB classB = new ClassB();  13. classB.getValue();  14. }  15. }  And:  20. class ClassB {  21. public ClassC classC;  22.  23. public String getValue() {  24. return classC.getValue();  25. }  26. }  And:  30. class ClassC {  31. public String value;  32.  33. public String getValue() {  34. value = “ClassB”;  35. return value;  36. }  37. }  Given:  ClassA a = new ClassA();  a.methodA();  What is the result?()A Compilation fails.B ClassC is displayed.C The code runs with no output.D An exception is thrown at runtime.

单选题GPRS服务类型有CLASS A、CLASS B、CLASS C三种:()在上网的时候会将电话功能屏蔽,当有电话进来的时候自动切断网络;()可以同时使用网络和电话功能;()则是单纯的网络应用, 不提供电话功能。ACLASSB;CLASSA;CLASSCBCLASSA;CLASSB;CLASSCCCLASSC;CLASSB;CLASSADCLASSC;CLASSA;CLASSB