vietjack.com

400 Câu hỏi trắc nghiệm lập trình C/C++ có đáp án (Phần 8)
Quiz

400 Câu hỏi trắc nghiệm lập trình C/C++ có đáp án (Phần 8)

A
Admin
50 câu hỏiIT TestTrắc nghiệm tổng hợp
50 CÂU HỎI
1. Nhiều lựa chọn

What is the output of the following code? Media VietJack

A. 21,21

B. 20,21

C. 21,22

D. compile error

2. Nhiều lựa chọn

What is the output of the following code? Media VietJack

A. 100

B. 101

C. none

D. compile error

3. Nhiều lựa chọn

The design of classes in a way that hides the details of implementation from the user is known as:

A. Encapsulation

B. Information Hiding

C. Data abstraction

D. All of the above

4. Nhiều lựa chọn

Which of the following keywords do you think can be used when declaring static members in a class?
(i) Public
(ii) Private
(iii) Protected

A. all of above

B. (i)

C. (i), (iii)

5. Nhiều lựa chọn

I want a nonmember function to have access to the private members of a class. The class must declare that function:

A. friend

B. inline

C. static

D. virtual

6. Nhiều lựa chọn

The ability to reuse objects already defined, perhaps for a different purpose, with modification appropriate to the new purpose, is referred to as

A. Information hiding

B. Inheritance

C. Redefinition

D. Overloading

7. Nhiều lựa chọn

What do you think is the outcome of calling a redefined non-virtual function using a base-class pointer?

A. The appropriate redefined version of the function will be used

B. The base-class version of the function will always be used

C. The outcome is unpredictable

D. A run-time error will occur

8. Nhiều lựa chọn

A class member that is to be shared among all objects of a class is called

A. A const member

B. A reference parameter

C. A static member

D. A function member

9. Nhiều lựa chọn

What is a base class?

A. An abstract class that is at the top of the inheritance hierarchy.

B. A class with a pure virtual function in it.

C. A class that inherits from another class

D. A class that is inherited by another class, and thus is included in that class.

10. Nhiều lựa chọn

A variable that is declared protected:

A. Is visible only in the subclasses (and not in the class it is declared in)

B. Is visible only in the class it is declared in

C. Is visible to all classes, but modifiable only in the class where it is declared

D. Is visible in the class it is declared in, and all of its sub-classes

11. Nhiều lựa chọn

What is a destructor?

A. A function called when an instance of a class is initialized

B. A function that is called when an instance of a class is deleted

C. A special function to change the value of dynamically allocated memory

D. A function that is called in order to change the value of a variable

12. Nhiều lựa chọn

In protected inheritance:

A. The public members of the base class become public

B. The public members of the base class become protected

C. The protected members of the base class become private

D. The public members of the base class become inaccessible

13. Nhiều lựa chọn

If a class declares a variable static, this means:

A. Each instance of a class will have its own copy of the variable

B. Changing the variable in one instance will have no effect on other instances of the class

C. Changing the variable in one instance will have no effect on other instances of the class

D. Every instance of the class must consider the value of the static variable before initializing

14. Nhiều lựa chọn

In case of a copy constructor, which of the following is true?

A. Used to instantiate an object from another existing object

B. To copy one object to another existing object

C. Can be a substitute for a ‘=’ operator

D. All of the above

15. Nhiều lựa chọn

A class declaring another class as a friend will:

A. Have wine and cheese with that other friend

B. Allow that class to declare an instance of it in its list of private variables

C. Allow the other class (the one declared as friend) to access to the declaring class’s private variables

D. Allow the class declaring the other as a friend to access the declared class’s private variables

16. Nhiều lựa chọn

Which of the following can be virtual?

A. constructors

B. destructors

C. static functions

D. None of the above

17. Nhiều lựa chọn

Where is an exception generated?

A. In the catch block

B. In the throw clause

C. In the constructor of a class

D. Only when memory allocation fails

18. Nhiều lựa chọn

Static member functions ___

A. can be used without an instantiation of an object

B. can only access static data

C. Both 1 and 2 are correct

D. Neither 1 nor 2 are correct

19. Nhiều lựa chọn

What makes a class abstract?

A. The class must not have method

B. The class must have a constructor that takes no arguments

C. The class must have a function definition equal to zero

D. The class may only exist during the planning phase

20. Nhiều lựa chọn

In the following program, how many times Base’s constructor will be called? Media VietJack

A. 1

B. 2

C. 3

D. error

21. Nhiều lựa chọn

In the following code what would be the values of i1 and i2 Media VietJack

A. i1=2 i2=2

B. i1=2 i2=3

C. i1=3 i2=2

D. Error

22. Nhiều lựa chọn

In the following code, which of the following variables can be accessed in “Friend”? Media VietJack

A. only a and b

B. a,b and c

C. only a

D. error

23. Nhiều lựa chọn

What is the output of the following code? Media VietJack

A. 0

B. 5

C. 6

D. 7

24. Nhiều lựa chọn

What is wrong in the following code? Media VietJack

A. There is nothing wrong

B. One cannot have a ‘Base’ pointer to ‘Derived’ since it is not derived publicly

C. One need a derived class pointer to point to a derived class

D. One required to code a constructor for Derived

25. Nhiều lựa chọn

What is the output of the following code? Media VietJack

A. professor researcher teacher myprofessor

B. researcher professor teacher myprofessor

C. myprofessor teacher researcher professor

D. myprofessor researcher professor teacher

26. Nhiều lựa chọn

What is the output of the following code? Media VietJack

A. Parent Parent

B. Parent Child Child Parent

C. Child Parent Parent Child

D. Error

27. Nhiều lựa chọn

What is wrong in the following code? Media VietJack

A. There is no error

B. There is a syntax error in the declaration of “Method”

C. Class D2 does not have access to “Method”

D. Class D1 must define “Method”

28. Nhiều lựa chọn

Quy tắc đặt tên biến nào sau đây là đúng?

A. Là một chuỗi gồm một hoặc nhiều ký tự chữ, số hoặc ký tự gạch dưới, bắt đầu bằng một ký tự hoặc dấu gạch dưới.

B. Không chứa các ký hiệu Đểc biệt hoặc dấu cách.

C. Không trùng với các từ khoá.

D. Tất cả các quy tắc đầu đúng.

29. Nhiều lựa chọn

Kích thước của dữ liệu kiểu char là bao nhiêu byte?

A. 1

B. 2

C. 4

D. 8

30. Nhiều lựa chọn

Khai báo biến nào sau đây là SAI?

A. double d = 3.14;

B. int num = 10;

C. long lint = 8;

D. short int = 5;

31. Nhiều lựa chọn

Khai báo nào sau đây là ĐÚNG?

A. signed a;

B. sign double d;

C. unsign int i;

D. longth t;

32. Nhiều lựa chọn

Biến toàn cục là gì?

A. Biến khai báo trong thân một hàm hoặc một khối lệnh.

B. Biến khai báo trong thân main, hoặc bên ngoài tất cả các hàm.

C. Cả hai đáp án đầu đúng.

33. Nhiều lựa chọn

Biến cục bộ là dạng biến gì? Chọn câu trả lời đúng nhất.

A. Là biến khai báo trong thân hàm main

B. Là biến khai báo trong thân một khối lệnh

C. Là biến khai báo trong thân một hàm

D. Là biến khai báo trong một hàm hoặc một khối lệnh

34. Nhiều lựa chọn

Chuỗi ký tự (string) là gì?

A. Các giá trị không phải là số và có độ dài là 1

B. Các giá trị số lớn hơn 0

C. Các biến có giá trị true hoặc false

D. Các giá trị cả chữ và số, nằm trong 2 dấu nháy “” và kết thúc với ký tự null

35. Nhiều lựa chọn

Lệnh nào sau đây là SAI?

A. string s = 1234;

B. string s (“Hello world!”);

C. string s = “Hello world!”;

D. Tất cả đầu đúng

36. Nhiều lựa chọn

Khai báo nào sau đây là SAI?

A. char c = “a”;

B. int i = 75ul;

C. int i = 0013;

D. int i = 0x4b

37. Nhiều lựa chọn

Lệnh nào sau đây định nghĩa một hằng giá trị?

A. const PI = 3.1415;

B. #define PI 3.1415

C. #define PI = 3.1415

D. const float PI;

38. Nhiều lựa chọn

Đoạn lệnh sau có kết quả bao nhiêu? Media VietJack

A. Một giá trị bất kỳ

B. 5

C. 7

D. Lỗi biên dịch

39. Nhiều lựa chọn

Lệnh nào sau đây là SAI?

A. cout << 120;

B. Không có lệnh sai

C. int x; cout << x;

D. int age = 33; cout << “My age is “ << age << “.\n”;

40. Nhiều lựa chọn

Nguyên lý của cấu trúc while là:

A. Chương trình sẽ lặp đi lặp lại khối lệnh cho đến khi biểu thức điều kiện bằng 0.

B. Chương trình sẽ lặp đi lặp lại khối lệnh cho đến khi biểu thức điều kiện sai.

C. Chương trình sẽ lặp đi lặp lại khối lệnh cho đến khi biểu thức điều kiện đúng.

D. Không có đáp án đúng.

41. Nhiều lựa chọn

Kết quả đoạn lệnh sau là bao nhiêu? Media VietJack

A. Lỗi biên dịch

B. 0,1,4,9,

C. Lặp vĩnh viễn

D. 0,1,4,

42. Nhiều lựa chọn

Kết quả đoạn lệnh sau là bao nhiêu? Media VietJack

A. 0,1,4,

B. Lặp vĩnh viễn

C. Lỗi biên dịch

D. 0,1,4,9,

43. Nhiều lựa chọn

Kết quả đoạn lệnh sau là bao nhiêu? Media VietJack

A. Lỗi biên dịch

B. Lặp vĩnh viễn

C. 0,1,4,

D. 0,1,4,9

44. Nhiều lựa chọn

Kết quả đoạn lệnh sau là bao nhiêu? Media VietJack

A. Lặp vĩnh viễn

B. 0,1,2,

C. Lỗi biên dịch

D. 0,1,

45. Nhiều lựa chọn

Kết quả đoạn lệnh sau là bao nhiêu? For (int i = 0,n = 5; n != i; i++,n--) cout << i << “,”; Media VietJack

A. 0,1,2,

B. Lặp vĩnh viễn

C. Lỗi biên dịch

D. 0,1,

46. Nhiều lựa chọn

Cách khai báo hàm nào sau đây là đúng?

A. <Tên hàm> { Khối lệnh }

B. <Kiểu dữ liệu trả về> <Tên hàm> (Tham số 1, Tham số 2,..) { Khối lệnh}

C. <Tên hàm> (Tham số 1, Tham số 2,..) { Khối lệnh }

D. <Kiểu dữ liệu trả về> :<Tên hàm> (Tham số 1, Tham số 2,..) { Khối lệnh}

47. Nhiều lựa chọn

Thế nào là truyền tham trị? Chọn câu trả lời đúng nhất

A. Truyền bản sao của tham số vào biến. Tất cả các thay đổi của biến được thực hiện bởi hàm không ảnh hưởng đến giá trị của biến bên ngoài hàm.

B. Truyền địa chỉ của biến vào hàm.

C. Truyền giá trị của tham số vào biến.

D. Truyền bản sao của biến vào hàm chứ không phải là bản thân biến

48. Nhiều lựa chọn

Thế nào là truyền tham biến? Chọn câu trả lời đúng nhất

A. Truyền giá trị của tham số vào biến.

B. Truyền bản sao của tham số vào biến. Tất cả các thay đổi của biến được thực hiện bởi hàm không ảnh hưởng đến giá trị của biến bên ngoài hàm.

C. Truyền địa chỉ của biến vào hàm.

D. Truyền bản sao của biến vào hàm chứ không phải là bản thân biến.

49. Nhiều lựa chọn

Hàm overloaded là những hàm như thế nào?

A. Các hàm trùng tên nhưng khác về cách khai báo tham số

B. Các hàm có cùng kiểu dữ liệu trả về

C. Không có đáp án đúng

D. Các hàm trùng tham số những khác nhau về tên

50. Nhiều lựa chọn

Mảng là gì? Chọn câu trả lời đúng nhất

A. Một chuỗi các phần tử cùng kiểu đặt trên các vị trí bộ nhớ khác nhau, trong đó mỗi phần tử có thể tham chiếu thông qua số chỉ mục và tên mảng.

B. Một chuỗi các phần tử khác kiểu được đặt trên các vị trí bộ nhớ liên tiếp nhau, trong đó mỗi thành phần có thể được tham chiếu thông qua số chỉ mục và tên mảng.

C. Một chuỗi các phần tử cùng kiểu được đặt trên các vị trí bộ nhớ liên tiếp nhau, trong đó mỗi thành phần có thể được tham chiếu thông qua số chỉ mục và tên mảng.

D. Không có đáp án đúng

© All rights reserved VietJack