protected int blipvert(long x) { return 0; }
protected long blipvert(int x) { return 0; }
private int blipvert(long x) { return 0; }
private int blipvert(int x) { return 0; }
public int blipvert(int x) { return 0; }
protected long blipvert(long x) { return 0; }
protected long blipvert(int x, int y) { return 0; }
第1题:
有如下程序: #include <iostream> using namespace std; class Sample { friend long fun(Sample s); public: Sample(long a) {x=a;} private: long x; }; long fun(Sample s) { if(s.x < 2) return 1; return s.x * fun(Sample(s.x-1)); } int main() { int stun = 0; for (int i=0; i<6; i++) {sum += fun(Sample(i));} cout << sum; return 0; }运行时输出的结果是
A.120
B.16
C.154
D.34
第2题:
A.Foo { public int bar() { return 1; }
B.new Foo { public int bar() { return 1; }
C.new Foo() { public int bar() { return 1; }
D.new class Foo { public int bar() { return 1; }
第3题:
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int a; if(x==0‖x==1) return 3; else a=x-fun(x-2); return a; } void main() { printf("%d",fun(7)); }
A.2
B.8
C.9
D.5
第4题:
有以下程序: #include<iostream> using namespace std; int f(int x); int sum(int n) { int x,s=0; for(x = 0;x<=n;x++) s+=f(x); return s; } int f(int x) { return (x*x+1); } int main() { int a,b; cout<<"Enter a integer number:"; cin>>a; b=sum(a) ; cout<<a<<","<<b<<end1; return 0; } 如果输入数字3,其输出结果是( )。
A.3,12
B.3,16
C.3,18
D.4,20
第5题:
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int p; if(x==0‖x==1) return 3; else p=x-fun(x-2); return p; } void main() { printf("\n%d",fun(5)); }
A.5
B.3
C.7
D.1
第6题:
下列程序的输出结果是( )。#include<stdio.h>int fun(int x){ int a; if(x==0||x=1) return 3; else a=x-fun(x-2); return a;}void main(){ printf("%d",fun(7));}
A.2
B.8
C.9
D.5
第7题:
下列程序的输出结果是( )。
#include<stdio.h>
int fun(int x)
{ int p;
if(x==0‖x=1)
return 3;
else
p=x-fun(x-2) ;
return p;
}
void main()
{ printf("\n%d",fun(5) );
}
A.5
B.3
C.7
D.1
第8题:
class A { protected int method1(int a, int b) { return 0; } } Which two are valid in a class that extends class A?()
第9题:
1. class Over{ 2. int doIt(long x) { return 3;} 3. } 4. 5. class Under extends Over{ 6. //insert code here 7. } 和四个方法: short doIt(int y) {return 4;} int doIt(long x,long y){return 4;} private int doIt(Short y){ return 4;} protected int doIt(long x){return 4;} 分别插入到第6行,有几个可以通过编译?()
第10题:
1. public class Blip { 2. protected int blipvert(int x) { return 0; } 3. } 4. class Vert extends Blip { 5. // insert code here 6. } Which five methods, inserted independently at line 5, will compile?()
第11题:
protected int blipvert(long x) { return 0; }
protected long blipvert(int x) { return 0; }
private int blipvert(long x) { return 0; }
private int blipvert(int x) { return 0; }
public int blipvert(int x) { return 0; }
protected long blipvert(long x) { return 0; }
protected long blipvert(int x, int y) { return 0; }
第12题:
public int method1(int a, int b) { return 0; }
private int method1(int a, int b) { return 0; }
private int method1(int a, long b) { return 0; }
public short method1(int a, int b) { return 0: }
static protected int method1(int a, int b) { return 0; }
第13题:
下面函数的作用是【 】。
int index(int x,int a[],int n)
{
for(int i=0;i<n;i++)
{
if(a[i]==x)
return i;
}
return i;
}
第14题:
下列程序的输出结果是( )。
#include<stdio.h>
int fun(int x)
{ int a;
if(x==0‖x==1)
return 3;
else
a=x-fun(x-2) ;
return a;
}
void main()
{ printf("%d",fun(7) );
}
A.2
B.8
C.9
D.5
第15题:
下列程序的运行结果是______。
include<stdio.h>
long func(int x)
{ long p;
if(x==O‖x==1)
return(1);
p=x*func(x-1);
return(p);
}
main()
{ printf("%d\n",func(4));
}
本题考查函数的循环调用。p=x*func(x-1),当x=4时,不满足if语句的条件,p=4*func(3), x=3也不满足条件,则func(3)=3*func(2),func(2)=2*func(1),x=1满足条件return(1),则输出结果为 4*3*2*1=24。
第16题:
有如下程序: #inClude<iostream> using namespaCe std; Class Sample{ friend long fun(Sample S); publiC: Sample(10ng A.{x=a;} private: long X; }; long fun(Sample S){ if(S.x<2)return l; return S.X*fun(Sample(s.x-1)); } int main( ) { int sum=0; for(int i=0;i<6;i++) {sum+=fun(Sample(i));} Cout<<sum: return 0; } 执行这个程序的输出结果是( )。
A.120
B.16
C.154
D.34
第17题:
有以下程序 #include <stdio.h> int f(int x) { int y; if(x==0||x==1) return(3); y=x*x-f(x-2); return y; } main() { int z; z=f(3); printf("%d\n",z); } 程序的运行结果是
A.0
B.9
C.6
D.8
第18题:
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int p; if(x==0‖x==1) return 3; else p=x-fun(x-2); return p; } void main() { print f("\n%d", fun(5)); }
A.5
B.3
C.7
D.1
第19题:
有如下程序:
include<iostream>
using namespace std;
int fun1(int x) {return++x;}
int fun2(int &x) {return++x;}
int main(){
int x=1,y=2;
y=fun 1(fun2(x));
cout<<X<<','<<y;
return 0:
}
程序的输出结果是______。
第20题:
Given the following code, which method declarations, when inserted at the indicated position, will not cause the program to fail compilation?() public class Qdd1f { public long sum(long a, long b) { return a + b; } // insert new method declaration here }
第21题:
现有: 1.class Over { 2.int dolt (long x) { return 3; } 3. } 4. 5. class Under extends Over { 6.//insert code here 7. } 和四个方法: short dolt (int y) { return 4; } int dolt(long Xr long y) { return 4; } private int dolt(short y) { return 4; } protected int dolt (long x) { return 4; } 分别插入到第6行,有几个可以通过编译?()
第22题:
public int sum(int a, int b) { return a + b; }
public int sum(long a, long b) { return 0; }
abstract int sum();
private long sum(long a, long b) { return a + b; }
public long sum(long a, int b) { return a + b; }
第23题:
public int blipvert(int x) { return 0; }
private int blipvert(int x) { return 0; }
private int blipvert(long x) { return 0; }
protected long blipvert(int x, int y) { return 0; }
protected int blipvert(long x) { return 0; }
protected long blipvert(long x) { return 0; }
protected long blipvert(int x) { return 0; }
第24题:
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){}