public int add (long a);
public void add (int a);
public void add (long a);
public int add (float a);
第1题:
以下程序输出结果是( ): #include<iostream> using namespace std; void add(int X,int y,int *z) { *z=y+x; } int main() { int a,b,c; add(8,4,&a); add(6,a,&b); add(a,b,&c); cout<<a<<","<<b<<","<<c<<end1; return 0;
A.12,10,14
B.12,18,30
C.12,6,18
D.12,14,30
第2题:
如下程序是为变量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();
}
}
第3题:
下面程序的输出结果是【 】。
include<iostream.h>
int add(int a, int b);
void main()
{
extern int x, y;
cout<<add(x, y)<<end1;
}
int x(20),y(5);
int add(int a, int b)
{
int s=a+ b;
return s;
}
第4题:
指出下列哪个方法与方法public void add(int a){}为错误的重载方法()
A、public int add(int a)
B、public void add(long a)
C、public int add(long a)
D、public void add(float a)
第5题:
下列程序的输出结果是______。
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;
}
第6题:
指出下列方法与方法publicvoidadd(inta){}中为合理的重载方法的是()。
第7题:
下列方法中,与方法public void add(inta){}为合理重载的方法是()。
第8题:
interface A { public int getValue() } class B implements A { public int getValue() { return 1; } } class C extends B { // insert code here } Which three code fragments, inserted individually at line 15, make use of polymorphism?()
第9题:
public void example(intm){...}
public int example(){...}
public void example2(){...}
public int example(intm,floatF.{...}
第10题:
public void example2(){...}
public int example(){...}
public void example(intm){...}
public int example(intm,floatF.{...}
第11题:
public int cal(int x,int y,float z){return 0;}
public int cal(int x,int y,int z){return 0;}
public void cal(int x,int z){}
public viod cal(int z,int y,int x){}
第12题:
void setVar (int a, int b, float c){ x = a; y = b; z = c; }
public void setVar(int a, float c, int b) { setVar(a, b, c); }
public void setVar(int a, float c, int b) { this(a, b, c); }
public void setVar(int a, float b){ x = a; z = b; }
public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }
第13题:
下面程序段的输出结果是 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
第14题:
下列函数的运行结果是( )。 #include<iostream.h> int add(int a,int b); void main() { extern int x,y; cout<<add(x,y)(<endl; ) int x(20),y(5); int add(int a,intB) { int s=a+b; return s; }
A.25
B.30
C.20
D.15
第15题:
下列函数的运行结果是( )。 #include<iostream.h> int add(int a,int b); void main() { extem int x,y; cout<<add(x,y)<<endl; } int x(20),y(5); int add(int a,int b) { int s=a+b; return s; )
A.25
B.30
C.20
D.15
第16题:
下列程序段的执行结果为( )。 #include<iostream> using namespace std; class example{ int n; public: example(int i){n=i;} void add(){s+=n;} static int s; void pr(){ cout<<s<<endl; } }; int example::s=0; int fuc(char *x); int main(){ example x(2),y(3),z(4); x. add(); y. add(); z.pr(); return 0; }
A.2
B.3
C.5
D.6
第17题:
下列哪些是方法public int add (int a)的重载方法?()
第18题:
指出下列哪个方法与方法public void add(int a){? }为错误的重载方法()
第19题:
What will be written to the standard output when the following program is run?() 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 Qd073 { public static void main(String args[]) { bogo(new Extension()); } static void bogo(Base b) { b.add(8); b.print(); } }
第20题:
Private void setVar (int a, float c, int b) { }
Protected void setVar (int a, int b, float c) { }
Public int setVar (int a, float c, int b) (return a;)
Public int setVar (int a, int b, float c) (return a;)
Protected float setVar (int a, int b, float c) (return c;)
第21题:
public int add (long a);
public void add (int a);
public void add (long a);
public int add (float a);
第22题:
public void add(C c) { c.getValue(); }
public void add(B b) { b.getValue(); }
public void add(A a) { a.getValue(); }
public void add(A a, B b) { a.getValue(); }
public void add(C c1, C c2) { c1.getValue(); }
第23题:
public int add(inta)
public void add(longa)
public void add(inta,intb)
public void add(floata)
第24题:
public int add(int a)
public void add(long a)
public void add(int a)
public void add(int a,int b)