1 Introduction

Test 1

1、单选题:
‌What is the output of the following program fragment?‍‌int a = 3, b = 4;‍‌int& r = a;‍‌r = b;‍‌r = 6;‍‌std::cout << a << std::endl;‍‌‍
选项:
A: 7
B: 6
C: 4
D: 3
答案: 【 6

2、单选题:
‎What is the return type of ‘new int’?‍
选项:
A: int
B: int &
C: int *
D: void
答案: 【 int *

3、单选题:
‎char* p = new char(65); ‌‎What's the memory release statement ?‌‎‌
选项:
A: delete p;
B: delete [] p;
C: free(p);
D: delete <char> p;
答案: 【 delete p;

4、单选题:
‌char* p = new char[65];‎‌What's the memory release statement ?‎‌‎
选项:
A: free p;
B: free p[];
C: delete *p;
D: delete [] p;
答案: 【 delete [] p;

5、单选题:
​Which of the following statements is true?‌
选项:
A: The number of parameters for multiple overloaded functions must be different.
B: There are two functions with the same parameter list and different return value types. These two functions are overloaded functions.
C: When calling a function with both the second and third parameters having default values, you can only write the third argument while not writing the second argument.
D: The purpose of using inline functions is to improve the running speed of the program.
答案: 【 The purpose of using inline functions is to improve the running speed of the program.

6、单选题:
‎If the function declaration is void fun (char * a, int n, int & m); ‎‎Which of the following statements is true ?‎
选项:
A: char str[10];int *p, m;fun( str, m, p ); 
B: char *p = new char[10];int n, m;fun( p, m, &n ); 
C: char *p = new char[10];int n, m;fun( p, m, n ); 
D: char *p = new char[10];int n;fun( p, &n, 6 ); 
答案: 【 char *p = new char[10];int n, m;fun( p, m, n ); 

7、单选题:
‎The legal comments for C++ is‎
选项:
A: /*This is a C++ program/*
B: // This is a C++ program
C: “This is a C++ program”
D: /*This is a C++ program//
答案: 【 // This is a C++ program

8、单选题:
‏The steps of developing C ++ program are‌
选项:
A: edit, debug, compile, connect
B: compile, debug, edit, connect
C: compile, edit, connect, run
D: edit, compile, connect, run
答案: 【 edit, compile, connect, run

9、单选题:
‍Function overloading means‌
选项:
A: Two or more functions have the same function name, but the number or type of parameters are different
B: Two or more functions have the same name and the same number of parameters, but the types of parameters can be different
C: Two or more functions have different names, but the number or type of parameters are the same
D: Two or more functions have the same function name and return type
答案: 【 Two or more functions have the same function name, but the number or type of parameters are different

10、单选题:
‌About C++ and C language, which of the following statements is wrong?‍
选项:
A: C is a subset of C++
B: C program can run in C++ environment
C: C++ program can run in C environment
D: C++ is object-oriented and C is process-oriented
答案: 【 C++ program can run in C environment

2 Class and Object

Test 2

1、单选题:
‍What is the incorrect statement about “class” and “object”?‎
选项:
A: Class is a data type. It encapsulates data and functions.
B: Object is an instance of the class.
C: There is only one object for a class.
D: An object must belong to a class
答案: 【 There is only one object for a class.

2、单选题:
‎Which of the following statements is incorrect?‍
选项:
A: A class can have many member functions with the same name
B: In a class, we can declare objects of another other class as its data members
C: The definition of a class should end with a semicolon.
D: The storage space allocated by the system for the class can be calculated by "sizeof"
答案: 【 The storage space allocated by the system for the class can be calculated by "sizeof"

3、单选题:
‏A member function in class A is described as void set(A &a);,where A &a means_______​
选项:
A: The pointer to class A is a
B: Assign the address of a to the variable set
C: a is the object reference of class A, which is used as the parameter of function set()
D: a is an independent object of class A, which is used as the parameter of function set()
答案: 【 a is the object reference of class A, which is used as the parameter of function set()

4、单选题:
​Function void f() is a public member function in class A. Which of the following statements is wrong?‎
选项:
A: A a; a.f();
B: A a; A*a1 = &a; a1->f();
C: A a; A &a1 = a; a1->f();
D: A a; A &a1 = a; a1.f();
答案: 【 A

剩余75%内容付费后可查看

发表评论

电子邮件地址不会被公开。 必填项已用*标注