1.classA{2.publicintgetNumber(inta){3.returna+1;4.}5.}6.7.classBextendsA{8.publicintgetNumber(inta){9.returna+210.}11.12.publicstaticvoidmain(Stringargs[]){13.Aa=newB();14.System.out.printIn(a.getNumber(0));15.}16.}Whatistheresult?()A.Compilationsucceedsand1isprinted.B.Compilationsucceedsand2isprinted.C.Anerroratline8causescompilationtofail.D.Anerroratline13causescompilationtofail.E.Anerroratline14causescompilationtofail.
1.classA{2.publicintgetNumber(inta){3.returna+1;4.}5.}6.7.classBextendsA{8.publicintgetNumber(inta){9.returna+210.}11.12.publicstaticvoidmain(Stringargs[]){13.Aa=newB();14.System.out.printIn(a.getNumber(0));15.}16.}Whatistheresult?()
A.Compilationsucceedsand1isprinted.
B.Compilationsucceedsand2isprinted.
C.Anerroratline8causescompilationtofail.
D.Anerroratline13causescompilationtofail.
E.Anerroratline14causescompilationtofail.
相关考题:
有如下程序:includeusing namespace std;class A{public:static int a;void init(){a 有如下程序: #include<iostream> using namespace std; class A{ public: static int a; void init(){a=1;} A(int a=2){init(); a++;} }; int A::a=0; A obj; int main() { cout<<obj.a; return 0; 运行时输出的结果是( )。A.0B.1C.2D.3
有如下程序:includeusing namespace std;class A{public: static int a; void init 有如下程序:#include<iostream>using namespace std;class A{public: static int a; void init(){a=1;} A(int a=2){init();a++;}};int A::a=0;A obj;int main(){ cout<<obj.a; return 0;}运行时输出的结果是A.0B.1C.2D.3
1.classA{2.publicbytefileNumber(){3.returnl;4.}5.}6.7.ClassBextendsA{8.publicshortgetNumber(){9.return2;10.}11.12.publicshortgetNumber(){13.Bb=newB();14.System.out.printIn(b.getNumber());15.}16.}Whatistheresult()?A.Compilationsucceedsandlisprinted.B.Compilationsucceedsand2printed.C.Anerroratline8causecompilationtofail.D.Anerroratline14causecomplicationtofail.E.Complicationsucceedsbutanexceptionisthrownatline14.
1.classA{2.publicbytegetNumber(){3.return1;4.}5.}6.7.classBextendsA{8.publicshortgetNumber(){9.return2;10.}11.12.publicstaticvoidmain(Stringargs[]){13.Bb=newB();14.System.out.printIn(b.getNumber())15.}16.}Whatistheresult?()A.Compilationsucceedsand1isprinted.B.Compilationsucceedsand2isprinted.C.Anerroratline8causescompilationtofail.D.Anerroratline14causescompilationtofail.E.Compilationsucceedsbutanexceptionisthrownatline14.
下面这个程序的结果是includeclass A{private:int a;public:void seta( );int geta 下面这个程序的结果是 #include<iostream.h> class A { private: int a; public: void seta( );int geta( );}; void A::seta( ) { a = 1;} int A::geta( ) {return a;} classA.1B.2C.随机输出1或2D.程序有错
下面程序的输出结果是【】。 include using namespace std; class A {int a,b; public:A 下面程序的输出结果是【 】。include <iostream>using namespace std;class A{int a, b;public:A(){a = b = 0;}A(int aa, int bb ) : a(aA) , b(bB){cout <<"a="<<a<<","<<"b="<<b<<",";}~A(){cout<<"D";};int main ( ){A x, y(2, 3);return 0;}
下面程序的结果为includeint c;class A{private:int a;static int b;public:A( ){a 下面程序的结果为 #include<iostream.h> int c; class A { private: int a; static int b; public: A( ) {a=0;c=0;} void seta( ){a++;} void setb( ){b++;}A.1 2 1B.1 2 2C.1 1 2D.2 2 2
若有以下程序:include using namespace std;class A{protected: int a;public: A() { 若有以下程序: #include <iostream> using namespace std; class A { protected: int a; public: A() { a=10; } }; class A1 : public A { public: A1() { a=a+1; } }; class A2 : public A { public: A2 () { a=a+2; } }; class B : public A1,public A2 { public: B(){} void print() { cout<<a<<end1; } }; int main ( ) { B obj; obj.print(); return 0; } 程序运行后的输出结果是( )。A.产生语法错误B.11C.12D.10
若有以下程序:include using namespace std;class A{private: int a;public: A(int 若有以下程序: #include <iost ream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<", "; } }; class B { private:A.10,10,10B.10,12,14C.8,10,12D.8,12,10