1.What value is stored in x after the following two statements are Dan Quayle once said, "Who’s responsible for the riots?. 20.Given the following function prototype: void fooint arr[];
Trang 1BÀI THI TRẮC NGHIỆM LẬP TRÌNH C TRÊN LINUX
ĐỀ SỐ: 501
Trang 21.What value is stored in x after the following two statements are
Dan Quayle once said, "Who’s responsible for the riots? The rioters." A
cout << "Dan Quayle once said, "Who\’s responsible for the riots? The rioters " ";
Trang 33.Which of the following will output "Yes" if the integer variable num is either 2, 3, 4, or 5?
Trang 4C
D
5.
Trang 7variable named num?
A
cout << num;
Trang 8the top of the program?
three integers passed in?
A
Trang 9C
D
13.
Trang 1620.Given the following function prototype:
void foo(int arr[]);
Which statement correctly passes the array to the function?
int arr[10]; foo(arr[10]);
Trang 17two-dimensional array of type double?
Trang 20int main(){
Foo f;
f->printMessage(); return 0;
Trang 21There are no public accessor methods.
members of the structure?
struct Point {
int x;
int y;
};
Trang 2330.Under the principle of information hiding, which class definition best encapsulated the variable named "x"?
A
B
C
Trang 2431.
Trang 26val1=2 val2=1 val1=2 val2=2 val1=2 val2=2
B
val1=0 val2=1 val1=0 val2=2 val1=0 val2=2
Trang 29In default constructor Printing
35.
Trang 32upon declaring the variable of type Foo?
Trang 34C
D
40.
Trang 35There should be no semicolon after the right curly brace in the
definition of the Foo class
int operator %(const Number &x, const Number &y);
Trang 38Dan Quayle once said, "Who’s responsible for the riots? The rioters." A
cout << "Dan Quayle once said, "Who\’s responsible for the riots? The rioters " ";
Trang 43Before foo, X=1 In foo, X=2, After foo, X=2
Trang 44the top of the program?
Trang 45three integers passed in?
A
Trang 46C
D
16.
Trang 49void foo(int &);
Which of the following calls would give an error message?
Trang 50B
C
D
Trang 52A
B
Trang 53C
D
all elements in the array?
Trang 56int arr[10];
D
int[11] arr;
encapsulated the variable named "x"?
A
B
Trang 57D
27.
Trang 61"ID" cannot be all uppercase
A
We can specify member variables to be public or private within a class, but not within a struct.
B
A class allows member functions in addition to member variables while
a struct does not.
Trang 63Money m1(10,50), m2(10,50);
A
B
Trang 64In default constructor Printing
Trang 65In default constructor
In default constructor Printing
Printing
34.
Trang 66val1=2 val2=1 val1=2 val2=2 val1=3 val2=2
B
val1=2 val2=1 val1=2 val2=2 val1=2 val2=2
Trang 67val1=0 val2=1 val1=0 val2=2 val1=0 val2=2
D
val1=1 val2=1 val1=2 val2=2 val1=3 val2=2
35.
Trang 702 dollars and 50 cents 4 dollars and cents
upon declaring the variable of type Foo?
struct Stuff {
Trang 72A
B
C
Trang 74There should be no semicolon after the right curly brace in the
definition of the Foo class
D
The constructor must have a return type of void in the implementation
41.
Trang 766 7
B
6 8
Trang 777 8
D
7 9
43.
Trang 79BÀI THI TRẮC NGHIỆM
Trang 80C
D
3.
Trang 837.How can we input a value from the keyboard and store it in the variable named num?
Dan Quayle once said, "Who’s responsible for the riots? The rioters."
Trang 9010 4 10 4
void foo(int &);
Which of the following calls would give an error message? A
B
C
D
18.
Trang 93void foo(int arr[]);
Which statement correctly passes the array to the function? A
int arr[10]; foo(arr[0]);
Trang 96B
C
D
25.
Trang 98There are no private variables
There is a semicolon missing after the right curly brace
members of the structure?
struct Point {
int x;
int y;
};
Trang 99Point p; p:x = 10; p:y = 20;
B
Point p; p.x = 10; p.y = 20;
C
Point p; p::x = 10; p::y = 20;
D
Point p; p->x = 10; p->y = 20;
29.
Trang 100encapsulated the variable named "x"?
A
Trang 101C
D
Trang 104Printing
Trang 105In default constructor Printing
In default constructor Printing
C
In default constructor
In default constructor Printing
Trang 106val1=1 val2=1 val1=2 val2=2 val1=3 val2=2
B
val1=2 val2=1 val1=2 val2=2 val1=2 val2=2
Trang 107val1=0 val2=1 val1=0 val2=2 val1=0 val2=2
D
val1=2 val2=1 val1=2 val2=2 val1=3 val2=2
35.
Trang 110upon declaring the variable of type Foo?
Trang 1136 7
B
6 8
Trang 1147 8
D
7 9
42.