下面程序段的输出结果是 class Base { int i; Base() { add(1); } void add(int v) { i+=v; } void print() { System.out.println(i); } } class Extension extends Base { Extension() { add(2); } void add(int v) { i+=v*2; } } public class Test { public static void main(String args[]) { bogo(new Extension()); } static void bogo(Baseb){ b.add(8); b.print(); } }A.9B.18C.20D.22

下面程序段的输出结果是 class Base { int i; Base() { add(1); } void add(int v) { i+=v; } void print() { System.out.println(i); } } class Extension extends Base { Extension() { add(2); } void add(int v) { i+=v*2; } } public class Test { public static void main(String args[]) { bogo(new Extension()); } static void bogo(Baseb){ b.add(8); b.print(); } }

A.9

B.18

C.20

D.22


相关考题:

下列程序的输出结果是非曲直【 】。includeclass base{ int x, y;public: base(int i, 下列程序的输出结果是非曲直【 】。include<iostream, h>class base{int x, y;public:base(int i, int j){x=i; y=j;}virtual int add(){return x+ y;}};class three: public base{int z;public:three(int i, int j, int k) :base(i, j){z=k; }int add() { return (base:: add()+z); }};void main(){three * q=new three(lO,20,30);cout<<q->add()<<end1;}

下面程序的输出结果是【】。include using namespace std; class base { protected: int 下面程序的输出结果是【 】。include <iostream>using namespace std;class base{protected:int a;public:base(){cout<<"0":}};class basel: virtual public base{public:base1(){ cout<<"1";}};class base2 : virtual public base{public:base2(){cout<<"2";}};class derived : public base1,public base2{public:derived () {cout<<"3"; }}int main (){derived obj;cout<<end1;return 0;}

如下程序是为变量i赋值。若程序的输出结果是180。请将程序补充完整。注意:不改动程序结构,不得增行或删行。class Base{int i;Base(){add(10);}void add(int v){i+=v;}void print(){System.out.println(i);}}class Extension extends Base{Extension(){add(______);}void add(int v){i+=v*2;}}public class ConstructTest3{public static void main(String args[]){bogo(new Extension());}static void bogo(Base b){b.add(60);b.print();}}

下面程序段中的错误语句是 ______。 class M{ int i; public: void ~AA(int); AA *p; void AA(); void AA(int x){i=x;}; };A.AA *p;B.void ~AA(int);C.void AA(int);D.void AA(int x){i=x;};

下面程序段的输出结果是( )。 class Base { int i; Base { add(1); } void add(int v) { i+=v: } void print { System.out.println(i); } } class Extension extends Base { Extension { add(2); } void add(int v) { i+=v*2: } } public class Test { public static void main(String args[]) { bogo(new Extension); } static void bogo(Base b) { add(8); print; } }A.9B.18C.20D.22

下面程序的输出结果是()。include using namespace std;int fun (int, int);//fun ( ) 下面程序的输出结果是( )。 #include <iostream> using namespace std; int fun (int, int); //fun ( ) 函数的说明 void main( ) { int a =48,b =36,c; c = fun(a,B) ; cout<<c; } int fun(int u,int v) { int w; while (v) {w=u%v;u =v;v =w;} return u; }A.24B.12C.48D.36

下面程序段的输出结果是 class Base { int i; Base() { add(1); } void add(int v) { i+=v; } void print() { System.out.println(i); } } class Extension extends Base { Extension() { add(2); } void add(int v) { i+=*2; } } public class Test { public static void main(String args[]) { bogo(new Extension()); } static void bogo(Base b) { b.add(8); b.print(); } }A.9B.18C.20D.22

下面程序段的输出结果是( )。 classBase { inti; Base() { add(1); } voidadd(intV) { i+=v; } Voidphnt() { System.out.println(i); } } Class EXtenSiOneXtendSBaSe { ExtensiOn() { add(2); } voidadd(int v) { i+=v*2; } } public class TeSst { publicstatic voidmain(String argS[]) { bogo(new Extension()); } Static voidbogo(Base B) { b.add(8); b.phnt(); } }A.9B.18C.20D.22

下列程序的输出结果是______。 include class base { int x,y; public: base(int i,i 下列程序的输出结果是______。include<iostream.h>class base{int x,y;public:base(int i,int j){x=i;y=j;}virtual int add( ){return x+y;}};class three:public base{int z;public:three(int i,int j,int k):base(i,j){z=k;)int add( ){return(base::add( )+z);}};void main( ){three*q=new three(10,20,30);cout<<q->add( )<<endl;}