vietjack.com

700+ câu trắc nghiệm Ngôn ngữ lập trình C có đáp án - Phần 15
Quiz

700+ câu trắc nghiệm Ngôn ngữ lập trình C có đáp án - Phần 15

V
VietJack
Đại họcTrắc nghiệm tổng hợp5 lượt thi
25 câu hỏi
1. Trắc nghiệm
1 điểmKhông giới hạn

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]

Xem đáp án
2. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
3. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
4. Trắc nghiệm
1 điểmKhông giới hạn

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)

Xem đáp án
5. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
6. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
7. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
8. Trắc nghiệm
1 điểmKhông giới hạn

Which of the following operators can be applied on structure variables?

Equality comparison ( == )

Assignment ( = )

Both of the above

None of the above

Xem đáp án
9. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
10. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
11. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
12. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
13. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
14. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
15. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
16. Trắc nghiệm
1 điểmKhông giới hạn

What is output? #include #include #define MAX 1000 void main() { int MAX = 100; printf("%d ", MAX); getch(); }

1000

100

Complier error

Xem đáp án
17. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
18. Trắc nghiệm
1 điểmKhông giới hạn

A ____ is a special member function used to initialize the data members of a class.

constructor

destructor

static method

Xem đáp án
19. Trắc nghiệm
1 điểmKhông giới hạn

The default access for members of a class is ___ .

private

public

protected

protect

Xem đáp án
20. Trắc nghiệm
1 điểmKhông giới hạn

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

Xem đáp án
21. Trắc nghiệm
1 điểmKhông giới hạn

Inheritance enables ___ which saves time in development , and encourages using previously proven and high quality software.

reusability

encapsulation

development

Xem đáp án
22. Trắc nghiệm
1 điểmKhông giới hạn

The three member access specifiers are ___, ___ and ___ .

public, private, protected

public, private, protect

public, private, static

Xem đáp án
23. Trắc nghiệm
1 điểmKhông giới hạn

A “has a” relationship between classes represents ___ and an “is a” relationship between classes represent ___ .

containment, inheritance

hiding, inheritance

encapsulation, inheritance

Xem đáp án
24. Trắc nghiệm
1 điểmKhông giới hạn

A pure virtual function is specified by placing ___ at the end of its prototype in the class definition.

=0

=1

=-1

Xem đáp án
25. Trắc nghiệm
1 điểmKhông giới hạn

A operator ___ is called as de-referencing operator.

&

*

&&

Xem đáp án
© All rights reserved VietJack