rpd000013294 (1006966), страница 5
Текст из файла (страница 5)
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
A | C | B | A | A | A | B | A | A, B | A,B | A, B, C, D |
Контрольные вопросы ООП 3.doc
МОСКОВСКИЙ АВИАЦИОННЫЙ ИНСТИТУТ
(НАЦИОНАЛЬНЫЙ ИССЛЕДОВАТЕЛЬСКИЙ УНИВЕРСИТЕТ)
Инженерно-экономический институт (ИНЖЭКИН)
Кафедра 504 – «Экономическая информатика»
Контрольные вопросы для рубежного (промежуточного) контроля знаний №2
по дисциплине
«Объектно-ориентированное программирование»
Авторы:
доц. к.э.н. Дегтярев А.В.
Утверждено на заседании кафедры 504
Протокол №
От «___»_______20___ г.Вариант №1
1 | #include <iostream.h> void f1(const int &NoModifPar){NoModifPar;} void f2(int &NoModifPar){NoModifPar++;} void f3(const int NoModifPar){NoModifPar;} void f4(int NoModifPar){NoModifPar++;} void f5(const int *NoModifPar){NoModifPar++;} int main(void) { int No_Modif_Par; int &ref_No_Modif_Par = No_Modif_Par; No_Modif_Par=0; f1 (ref_No_Modif_Par); cout << "After f1() No_Modif_Par = " << No_Modif_Par << endl; No_Modif_Par=0; f2 (ref_No_Modif_Par); cout << "After f2() No_Modif_Par = " << No_Modif_Par << endl; No_Modif_Par=0; f3 (ref_No_Modif_Par); cout << "After f3() No_Modif_Par = " << No_Modif_Par << endl; No_Modif_Par=0; f4 (ref_No_Modif_Par); cout << "After f4() No_Modif_Par = " << No_Modif_Par << endl; No_Modif_Par=0; f5 (&ref_No_Modif_Par); cout << "After f5() No_Modif_Par = " << No_Modif_Par << endl; return 0; } Какой из вызовов функции на выходе даст значение 1? | Выберите один или несколько правильных ответов: G.void f1(const int &NoModifPar)H.void f2(int &NoModifPar)I.void f3(const int NoModifPar)J.void f4(int NoModifPar)K.void f5(const int *NoModifPar)L.Сообщение об ошибкеM.Не знаю |
2 | Статические методы подключаются на этапе . . . программы |
N.компиляции
|
3 | #include <iostream.h> #include <stdio.h> #include <string.h> int main(void) { char str1[]="cbmp"; char str2[]="ctmp"; FILE *fp=fopen("c:\io.text","w+"); fprintf(fp,"%s", str1); rewind(fp); fscanf(fp,"%s",str2); fclose(fp); cout << str1 << " " << str2 << " "; cin.get(); return 0; } | Выберите один, самый правильный ответ:
O.cbmp cbmp
|
Вариант №2
1 | #include <iostream.h> int main(void) { int x=5, y=12; //1========== if ( x + 2 > y - 1 ) cout <<"/1 Test Ok \n"; //2========== if ( x + 3 > (y - 4) ) cout <<"/2 Test Ok \n"; //3========== if ( x + ( y < 20 ) - 17 ) cout <<"/3 Test Ok \n"; //4========== if ( (x << 1) + 2 - y ) cout <<"/4 Test Ok \n"; //5========== if ( (y%2) && 2* (x >>2) ) cout <<"/5 Test Ok \n"; return 0; } Какой из вариантов выведет сообщение: “Test Ok”? | Выберите один , самый правильный ответ: A.2
B.1C.5D.3E.Сообщение об ошибкеF.не знаю |
2 | Каждый объект-родитель имеет . . . потомка/ов. |
G.Многих
|
3 | #include <iostream.h> int & Function(int & d) {cout << d << " "; d=98; return ++d;} int main(void) { int b=35, d= 45; int array[5] = {2,3,4,5,6}; Function(d)=b; int & c=Function(d); cout << c[array]; cin.get(); return 0; } | Выберите один, самый правильный ответ:
H.45 35 4
|
Вариант №3
1 | #include <stdio.h> int value=100; int main(void) { printf("%d ", value); int value=200; if (value > 10) { int value=1; printf("%d ", value); } printf("%d ", value); getchar(); return 0; } | Выберите один , самый правильный ответ: I.100 1 1
J.100 1 200K.100 200 200L.200 1 200M.Сообщение об ошибкеN.не знаю |
2 | Каждый объект-потомок имеет . . . родител(я/ей). | O.Одного
|
3 | #include <iostream.h> int & Function(int & d) {cout << d << " "; d=98; return ++d;} int main(void) { int b=35, d= 45; int array[5] = {2,3,4,5,6}; Function(d)=b; int & c=Function(d); cout << c[array]; cin.get(); return 0; } | Выберите один, самый правильный ответ:
P.45 35 4
|
Вариант №4
1 | #include <iostream.h> int main(void) { char buf[80]="xx"; int i=10; char * code="Unknow"; cout << "\n There are " << i << "object " << ends; cout << buf; cout << "\n The error code is " << code << ends; cout << buf; cin >> i; return 0; } | Выберите один , самый правильный ответ: Q.There are code is: Unknown
The error code is: Unknown xx
The error code is: Unknown
The error code is: UnknownR.Сообщение об ошибкеS.не знаю |
2 | С помощью позднего связывания подключаются . . . методы. | T.виртуальные
|
3 | #include <iostream.h> int main(void) { int x; int n=1,m=2; if (n/m>0) cout << "/1 Test OK"; x=10; if(!(x<100)) cout << "/2 Test OK"; x=0; if(!x<-100) cout << "/3 Test OK"; x=10; if((x!=0) && (1.0/(x<100))) cout << "/4 Test OK"; int a=1, b=2, c=3; if ((a>1) || (b<3) && (c == a/b)) cout << "/5 Test OK"; cin.get(); return 0; } | Выберите один, самый правильный ответ: A.“/4 Test OK”
|
Вариант №5
1 | #include <iostream.h> int a(int val) {return val;} int b(int val) {return val+val;} int c(int val) {return val+val+val;} int (*p[5])(int); int main(void) { p[0]=a; p[1]=b; p[2]=c; for (int i=0; i<3; i++) cout << c(i); cin.get(); return 0; } | Выберите один , самый правильный ответ: B.012
C.036D.026E.Сообщение об ошибкеF.не знаю |
2 | Конструктор и деструктор необходимы при использовании . . . методов | G.виртуальных
|
3 | #include <iostream.h> #include <string.h> #include <fstream.h> char a[9]="s", b[9]="d", c[9]= "h"; int i=8, j=9; int main(void) { fstream f("inout.txt", ios::in | ios::out | ios::trunc); f << "x\n" << 4 << "y\n" << 5 << "z"; f.seekp(0, ios::beg); f >> a >> i >> b >> j >> c; cout << a << b << c << ++i << j++; f.close(); cin.get(); return 0; } | Выберите один, самый правильный ответ: H.45xyz
|
Вариант №6
1 | #include <iostream.h> int main(void) { int x=2; ***** return 0; } Какой из вариантов напечатает “/x Test OK”, если его вставить в место отмеченное символами: *****?, где х - число | Выберите один или несколько правильных ответов: I.if (x=12)cout << "/4 Test OK \n";J.if (x!=2)cout << "/3 Test OK \n";K.if (x==12)cout << "/5 Test OK \n";L.if (!(x=12))cout << "/2 Test OK \n";M.if (x=x >>2)cout << "/1 Test OK \n";N.не знаю |
2 | Инициализация объекта происходит при использовании . . | O.конструктора
|
3 | #include <iostream.h> struct Student {char Name[40];}; Student & PrintStudentInfo(Student & st) {cout << st.Name << " "; return st;} Student st1 ={"Ivan"}, st2={"Sidor"}; int main(void) { PrintStudentInfo(st1)=st2; PrintStudentInfo(st1)=st1; cin.get(); return 0; } | Выберите один, самый правильный ответ: P.Sidor Ivan
Q.Ivan SidorR.Ivan Ivan
S.Не определена фугнкцияT.не знаю |
Вариант №7
1 | #include <iostream.h> int main(void) { int x=14; cout << dec << 16 << -2 << endl; //1 cout << dec << 20 << endl; //2 cout << hex << 14 << endl; //3 cout << dec << (16-2) << endl; //4 cout << dec << (14 << 1) << endl; //5 cin >> x; return 0; } Что выдает на экран сообщение: 14? | Выберите один, самый правильный ответ: U.cout << dec << 16 << -2 << endl;V.cout << dec << 20 << endl;W.cout << hex << 14 << endl;X.cout << dec << (16-2) << endl;Y.cout << dec << (14 << 1) << endl;Z.не знаю |
2 | Базой для технологии быстрой разработки приложений (RAD, Rapid Application Development) явилось визуальное . . . программирование. |
|
3 | #include <iostream.h> #include <stdio.h> #include <string.h> int main(void) { char str1[]="cbmp"; char str2[]="ctmp"; FILE *fp=fopen("c:\io.text","w+"); fprintf(fp,"%s", str1); rewind(fp); fscanf(fp,"%s",str2); fclose(fp); cout << str1 << " " << str2 << " "; cin.get(); return 0; } | Выберите один, самый правильный ответ:
AA.cbmp cbmp
|
Вариант №8
1 | #include <iostream.h> int main(void) { int x=14; cout << dec << 16 << -2 << endl; //1 cout << hex << 20 << endl; //2 cout << hex << 14 << endl; //3 cout << oct << 24 << endl; //4 cout << dec << (14 << 1) << endl; //5 cin >> x; return 0; } Что выдает на экран сообщение: 14? | Выберите один , самый правильный ответ: BB.cout << dec << 16 << -2 << endl;CC.cout << hex << 20 << endl;DD.cout << hex << 14 << endl;EE.cout << oct << 24 << endlFF.cout << dec << (14 << 1) << endl;GG.не знаю |
2 | Объект в ООП характеризуется набором таких характеристик, как |
|
3 | #include <iostream.h> class A {public: int foo() {return 1;}}; class B: virtual A {public: int foo() {return 2;}}; class C: virtual B {public: int foo() {return 3;}}; class D: virtual A, public B{}; int main(void) { D d; int i=d.foo(); cout << i << endl; cin.get(); return 0; } | Какой вывод следует ожидать?
HH.2
|
Вариант №9
1 | #include <iostream.h> enum{Red, Green, Blue}; int main(void) { enum {Blue, Green, Red}; cout << Blue << " " << (int) Blue << endl; cout <<::Blue<< " " << (int) ::Blue << endl; return 0; } | Выберите один , самый правильный ответ:
Blue Blue
3 3
Blue 3
2 2 II.Blue 0Blue 2 JJ.не знаю |
2 | На технологии RAD (Rapid Application Development) базируется система программирования . . . |
|
3 | #include <iostream.h> int & Function(int & d) {cout << d << " "; d=98; return ++d;} int main(void) { int b=35, d= 45; int array[5] = {2,3,4,5,6}; Function(d)=b; int & c=Function(d); cout << c[array]; cin.get(); return 0; } | Выберите один, самый правильный ответ:
KK.45 35 4
|
Вариант №10
1 | #include <iostream.h> class a { public: a() {count++;} ~a() {count--;} static int GetCount() {return 1;} private: static int count; }; int a::count=6; int main(void) { a* p=new a[5]; cout << a::GetCount(); delete[] p; cin.get(); return 0; } | Выберите один , самый правильный ответ:
LL.11MM.не знаю |
2 | Разрушение объекта происходит при использовании . . . |
|
3 | #include <iostream.h> int main(void) { int x; int n=1,m=2; if (n/m>0) cout << "/1 Test OK"; x=10; if(!(x<100)) cout << "/2 Test OK"; x=0; if(!x<-100) cout << "/3 Test OK"; x=10; if((x!=0) && (1.0/(x<100))) cout << "/4 Test OK"; int a=1, b=2, c=3; if ((a>1) || (b<3) && (c == a/b)) cout << "/5 Test OK"; cin.get(); return 0; } | Выберите один, самый правильный ответ: NN.“/4 Test OK”
|
Вариант №11
1 | #include "iostream.h" int main(void) { int n; double sum; for(sum=0,n=0; n<=3; sum=sum+n,n++); sum=sum+4; cout << sum << endl; int i; cin>>i; return 0; } | Выберите один , самый правильный ответ:
OO.10
|
2 | Объект-потомок может содержать |
|
3 | #include <iostream.h> #include <string.h> #include <fstream.h> char a[9]="s", b[9]="d", c[9]= "h"; int i=8, j=9; int main(void) { fstream f("inout.txt", ios::in | ios::out | ios::trunc); f << "x\n" << 4 << "y\n" << 5 << "z"; f.seekp(0, ios::beg); f >> a >> i >> b >> j >> c; cout << a << b << c << ++i << j++; f.close(); cin.get(); return 0; } | Выберите один, самый правильный ответ: PP.45xyz
|
Вариант №12
1 | #include <iomanip.h> #include <iostream.h> using namespace std; int main(void) { cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(3); cout <<upercase << sceintific; int n; double sum; for(sum=0,n=0; n<=3; sum=sum+n,n++); sum=sum+4; cout << sum << endl; int i; cin>>i; return 0; } | Выберите один , самый правильный ответ: QQ.1.000E+001
RR.Сообщение об ошибке
SS.10TT.не знаю |
2 | Данные объекта-родителя . . . в объекте-потомке | UU.Не описываются
|
3 | #include <iostream.h> struct Student {char Name[40];}; Student & PrintStudentInfo(Student & st) {cout << st.Name << " "; return st;} Student st1 ={"Ivan"}, st2={"Sidor"}; int main(void) { PrintStudentInfo(st1)=st2; PrintStudentInfo(st1)=st1; cin.get(); return 0; } | Выберите один, самый правильный ответ: VV.Sidor Ivan
WW.Ivan SidorXX.Ivan Ivan
YY.Не определена фугнкцияZZ.не знаю |
Ответы:
Вариант: | 1 | 2 | 3 |
1 | B | B | B |
2 | E | C | J |
3 | C | A | P |
4 | B | A | A |
5 | J | A | 4 |
6 | A,B,C,E | A | C |
7 | D | A | I |
8 | B | A,B,C,D | C |
9 | K | A,B,E,F | D |
10 | E | B | A |
11 | F | A,B,C,D | D |
12 | D | A | C |
Контрольные вопросы ООП 4.doc