浙商银行2011.11.26校园招聘会笔试题

来源:互联网 发布:网络平台可加盟 编辑:程序博客网 时间:2024/04/24 19:02

1、下列4行代码是否有错误,若有错误请指出,若没有,请确定a的值是多少?

int main(void){    int a = 3;    a += (a++);        //7    a += (++a);        //8    (++a) += (a++);    //9    (a++) += a;        //a++不是左值,是右值    return 0;}

2、下面代码的输出是多少?

int main(void){FILE *fp;char str[100];fp=fopen("myfile.dat","w");fputs("abc",fp);fclose(fp);fp=fopen("myfile.data","a++");fprintf(fp,"%d",28);rewind(fp);fscanf(fp,"%s",str);puts(str);fclose(fp);return 0;}

3、下面代码的输出是(B

class Myclass{public:Myclass(int n) { number = n;}Myclass(Myclass &other){number = other.number;cout<<"a ";}private:int number;};Myclass fun(Myclass p){Myclass temp(p);return temp;}int main(void){Myclass obj1(10),obj2(0);Myclass obj3(obj1);obj2=fun(obj3);return 0;}

A、a a a               B、a  a  a  a                 C、a  a                          D、a     

定义对象obj3的时候,调用了对象赋值函数,输出了a,调用函数fun的时候,先调用对象赋值函数把对象obj3赋值给了p,然后又一次调用对象赋值函数赋值给了temp对象,最后把函数返回值又赋值给了对象obj2,共调用了4次,所以输出了4个a。

4、下面代码的输出是(A

class Myclass{public:Myclass(int n) { number = n;}Myclass(Myclass &other){number = other.number;cout<<"a ";}private:int number;};Myclass fun(Myclass &p){Myclass temp(p);return temp;}int main(void){Myclass obj1(10),obj2(0);Myclass obj3(obj1);obj2=fun(obj3);return 0;}

A、a a a               B、a  a  a  a                 C、a  a                          D、a    

由于函数fun的是传引用参数,没有进行对象的赋值,只是在函数内部进行了一次对象之间的赋值,所以比上一题少了一次调用,所以就输出了3个a。

5、下面错误的是()

A、define N 10;

int x[N];

B、int N = 10;                   //这个是错误的,数组的大小应该是一个常量表达式
 int x[N];

C、const int N = 10;          //这个是正确的
 int x[N];

D、int x[0..10];

E、int x[];
简答题:

1、abstract class 和interface的区别?

2、数据库中索引的作用的什么?什么情况下适合建立索引及什么情况下不适合建立索引?

3、黑盒测试和白盒测试的优缺点各是什么?


 

原创粉丝点击