25 câu hỏi
What is output? #include #include void swap(char **, char **); int main() { char *pstr[2] = {"LAPTRINHC++", ".NET"}; swap(&pstr[0], &pstr[1]); printf("%s%s", pstr[0], pstr[1]); getch(); } void swap(char **t1, char **t2) { char *t; t=*t1; *t1=*t2; *t2=t; }
LAPTRINHC++.NET
NETLAPTRINHC++
Address of pstr[0] Address of pstr[1]
What is output? Giả sử dùng VC++ 2008 trên hệ điều hành 32 bit #include #include typedef struct { char c; // 1 byte float b; // 4 byte int a; // 4 byte }A; void main() { printf("\n Size of struct: %d", sizeof(A)); getch(); }
9
12
16
24
What is output? #include #include typedef struct { int a[2]; // 8 byte char b[5]; // 5 byte char c[5]; // 5 byte }A; void main() { printf("\n Size of struct: %d",sizeof(A)); getch(); }
20
18
32
24
What is output? #include #include struct birthday { int d; // day int m; // month int y; // year }; struct info { int ID; // code of staff birthday b; }; void main() { info a = {1009, 16, 9, 1989}; printf("\nID=%d, dd/mm/yyyy = %d/%d/%d",a.ID,a.b.d,a.b.m,a.b.y); getch(); }
ID=1009, dd/mm/yyyy = 16/09/1989
ID = 1009, dd/mm/yyyy = garbage value/garbage value/garbage value (garbage value: giá trị rác)
Error sytax (Lỗi cú pháp)
What is output? #include #include void main() { struct site { char name[] = "laptrinhc++"; int year = 2; }; struct site *ptr; printf("%s ", ptr->name); printf("%d", ptr->year); getch(); }
laptrinhc++ 2
Complier error
Runtime error
What is output? #include #include typedef struct { int x; static int y; }st; void main() { printf("sizeof(st) = %d", sizeof(st)); getch(); }
4
Complier error
8
What is output? #include #include struct { short s[5]; union { float y; long z; }u; } t; void main() { printf("sizeof(st) = %d", sizeof(t)); getch(); }
16
22
32
18
Which of the following operators can be applied on structure variables?
Equality comparison ( == )
Assignment ( = )
Both of the above
None of the above
What is output? #include #include #define x 5+2 void main() { int i; i = x*x*x; printf("%d", i); getch(); }
21
27
Complier Error
Another
What is output? #include #include #define call(x,y) x##y void main() { int x = 5, y = 10, xy = 20; printf("%d", xy + call(x, y)); getch(); }
530
70
40
Complier Error
What is output? #include #include #if X == 3 #define Y 3 #else #define Y 5 #endif void main() { printf("Y = %d", Y); getch(); }
Y = 3
Y = 5
Garbage value
What is output? #include #include #define X 3 #if !X printf("C/C++"); #else printf("Java"); #endif void main() { getch(); }
C/C++
Java
Complier error
What is output? #include #include #define ISEQUAL(X, Y) X == Y void main() { #if ISEQUAL(X, 0) printf("C/C++"); #else printf("Java"); #endif getch(); }
C/C++
Java
Complier error
What is output? #include #include #define SQUARE(x) x*x void main() { int x; x = 36 / SQUARE(6); printf("%d", x); getch(); }
1
36
6
30
What is output? #include #include #define a 10 void main() { printf("%d ", a); #define a 50 printf("%d ", a); getch(); }
10 50
10 10
50 50
What is output? #include #include #define MAX 1000 void main() { int MAX = 100; printf("%d ", MAX); getch(); }
1000
100
Complier error
What is output? #include #include #define PRINT(i, limit) do \ { \ if (i++ < limit) \ { \ printf("laptrinhc++"); \ continue; \ } \ }while(1) void main() { PRINT(0, 3); getch(); }
>
‘laptrinhc++’ is printed 3 times
‘laptrinhc++’ is printed 2 times
Complier error
A ____ is a special member function used to initialize the data members of a class.
constructor
destructor
static method
The default access for members of a class is ___ .
private
public
protected
protect
Member functions of a class are normally made ___ and data members of a class are normally made ___ .
private, public
protected, public
public, private
public, protected
Inheritance enables ___ which saves time in development , and encourages using previously proven and high quality software.
reusability
encapsulation
development
The three member access specifiers are ___, ___ and ___ .
public, private, protected
public, private, protect
public, private, static
A “has a” relationship between classes represents ___ and an “is a” relationship between classes represent ___ .
containment, inheritance
hiding, inheritance
encapsulation, inheritance
A pure virtual function is specified by placing ___ at the end of its prototype in the class definition.
=0
=1
=-1
A operator ___ is called as de-referencing operator.
&
*
&&
