C++ Programming MCQ (Multiple Choice Questions) - SchoolingAxis

C++ Programming MCQ (Multiple Choice Questions)

 Que- What is std in C++? 

a. std is a standard class in C++ 

b. std is a standard namespace in C++ 

c. std is a standard header file in C++ 

d. std is a standard file reading header in C++ 


Answer- std is a standard namespace in C++ 


Que- Which of the following is correct about static variables? 

a. Static functions do not support polymorphism 

b. Static data members cannot be accessed by non-static member functions 

c. Static data members functions can access only static data members 

d. Static data members functions can access both static and non-static data members 


Answer- Static data members functions can access only static data members 


Que- Const qualifier can be applied to which of the following?i) Functions inside a classii) Arguments of a functioniii) Static data membersiv) Reference variables 

a. i, ii and iii 

b. i, ii, iii, and iv 

c. ii, iii and iv 

d. i only 


Answer- i, ii, iii, and iv 


Que- What is the size of wchar_t in C++? 

a. 2 

b. 4 

c. 2 or 4 

d. Based on the number of bits in the system 


Answer- Based on the number of bits in the system 


Que- Pick the odd one out. 

a. array type 

b. character type 

c. boolean type 

d. integer type 


Answer- array type 


Que- Which data type is used to represent the absence of parameters? 

a. int 

b. short 

c. void 

d. float 


Answer- void 


Que- Which type is best suited to represent the logical values? 

a. integer 

b. boolean 

c. character 

d. float 


Answer- boolean 


Que- Identify the user-defined types from the following? 

a. enumeration 

b. classes 

c. both enumeration and classes 

d. int 


Answer- both enumeration and classes 


Que- Which of the following statements are true?int f(float) 

a. f is a function taking an argument of type int and returning a floating point number 

b. f is a function taking an argument of type float and returning an integer 

c. f is a function of type float 

d. f is a function of type int 


Answer- f is a function taking an argument of type float and returning an integer 


Que- The value 132.54 can be represented using which data type? 

a. double 

b. void 

c. int 

d. bool 


Answer- double 


Que- When a language has the capability to produce new data type mean, it can be called as 

a. overloaded 

b. extensible 

c. encapsulated 

d. reprehensible 


Answer- extensible 


Que- Pick the odd one out. 

a. integer, character, boolean, floating 

b. enumeration, classes 

c. integer, enum, void 

d. arrays, pointer, classes 


Answer- integer, enum, void 


Que- Is bool a fundamental data type in C++? 

a. Yes 

b. No, it is a typedef of unsigned char 

c. No, it is an enum of {false, true} 

d. No, it is expanded from macros 


Answer- Yes 


Que- Find the odd one out. 

a. std::vector<int> 

b. std::vector<short> 

c. std::vector<long> 

d. std::vector<bool> 


Answer- std::vector<bool> 


Que- What is the value of the bool? bool is_int(789.54) 

a. True 

b. False 

c. 1 

d. 2 


Answer- False 


Que- What happens when a null pointer is converted into bool? 

a. an error is flagged 

b. bool value evaluates to true 

c. bool value evaluates to false 

d. the statement is ignored 


Answer- bool value evaluates to false 


Que- Which of the following statements are false? 

a. bool can have two values and can be used to express logical expressions 

b. bool cannot be used as the type of the result of the function 

c. bool can be converted into integers implicitly 

d. a bool value can be used in arithmetic expressions 


Answer- bool cannot be used as the type of the result of the function 


Que- For what values of the expression is an if-statement block not executed? 

a. 0 and all negative values 

b. 0 and -1 

c. 0 

d. 0, all negative values, all positive values except 1 


Answer- 0 


Que- Which of the two operators ++ and -- work for the bool data type in C++? 

a. None 

b. ++ 

c. -- 

d. ++ & -- 


Answer- ++ 


Que- How many characters are specified in the ASCII scheme? 

a. 64 

b. 128 

c. 256 

d. 24 


Answer- 128 


Que- Given the variables p, q are of char type and r, s, t are of int type. Select the right statement? (1) t = (r * s) / (r + s); (2) t = (p * q) / (r + s); 

a. 1 is true but 2 is false 

b. 1 is false and 2 is true 

c. both 1 and 2 are true 

d. both 1 and 2 are false 


Answer- both 1 and 2 are true 


Que- Which of the following belongs to the set of character types? 

a. char 

b. wchar_t 

c. only a 

d. both wchar_t and char 


Answer- both wchar_t and char 


Que- How do we represent a wide character of the form wchar_t? 

a. L'a' 

b. l'a' 

c. L[a] 

d. la 


Answer- L'a' 


Que- In C++, what is the sign of character data type by default? 

a. Signed 

b. Unsigned 

c. Implementation dependent 

d. Unsigned Implementation 


Answer- Implementation dependent 


Que- Is the size of character literals different in C and C++? 

a. Implementation defined 

b. Can't say 

c. Yes, they are different 

d. No, they are not different 


Answer- Yes, they are different 


Que- Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char) return? 

a. 4 

b. 1 

c. Implementation dependent 

d. Machine dependent 


Answer- 1 


Que- What constant defined in <climits> header returns the number of bits in a char? 

a. CHAR_SIZE 

b. SIZE_CHAR 

c. BIT_CHAR 

d. CHAR_BIT 


Answer- CHAR_BIT 


Que- The size_t integer type in C++ is? 

a. Unsigned integer of at least 64 bits 

b. Signed integer of at least 16 bits 

c. Unsigned integer of at least 16 bits 

d. Signed integer of at least 64 bits 


Answer- Unsigned integer of at least 16 bits 


Que- Which of these expressions will return true if the input integer v is a power of two? 

a. (v 

b. (v + 1)) == 0; 

c. (~v & (v – 1)) == 0; 

d. (v 


Answer- (v – 1)) == 0; 


Que- What is the value of the following 8-bit integer after all statements are executed? int x = 1; x = x << 7; x = x >> 7; 

a. 1 

b. -1 

c. 127 

d. Implementation defined 


Answer- Implementation defined 

Previous Post Next Post

Responsive Ad