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

C++ Programming MCQ (Multiple Choice Questions)

 Que- What does the client module import? 

a. macro 

b. records 

c. interface 

d. instance 


Answer- interface 


Que- Identify the correct statement. 

a. c++ does not have built-in interfaces 

b. c++ does have built-in interfaces 

c. c++ have no concept of interfaces 

d. c++ does have built-in interfaces & classes 


Answer- c++ does not have built-in interfaces 


Que- What is similar to the interface in c++? 

a. methods 

b. instance of a class 

c. pure abstract class 

d. methods & instance of a class 


Answer- pure abstract class 


Que- Which of the following implements the module in the program? 

a. macro 

b. header files 

c. macro & header files 

d. interfaces 


Answer- header files 


Que- Which operator is used to signify the namespace? 

a. conditional operator 

b. ternary operator 

c. scope operator 

d. bitwise operator 


Answer- scope operator 


Que- Identify the correct statement. 

a. Namespace is used to group class, objects and functions 

b. Namespace is used to mark the beginning of the program 

c. A namespace is used to separate the class, objects 

d. Namespace is used to mark the beginning & end of the program 


Answer- Namespace is used to group class, objects and functions 


Que- What is the use of Namespace? 

a. To encapsulate the data 

b. To structure a program into logical units 

c. Encapsulate the data & structure a program into logical units 

d. It is used to mark the beginning of the program 


Answer- To structure a program into logical units 


Que- What is the general syntax for accessing the namespace variable? 

a. namespace::operator 

b. namespace,operator 

c. namespace#operator 

d. namespace$operator 


Answer- namespace::operator 


Que- Which keyword is used to access the variable in the namespace? 

a. using 

b. dynamic 

c. const 

d. static 


Answer- using 


Que- Pick the incorrect statement for namespaces in C++. 

a. Namespace declarations are always global scope 

b. Keyword namespace is used at the starting of a namespace definition 

c. Namespace has access specifiers like private or public 

d. Namespace definitions can be nested 


Answer- Namespace has access specifiers like private or public 


Que- Which operator is used for accessing a member of namespace? 

a. : 

b. :: 

c. -> 

d. . 


Answer- :: 


Que- What is the correct syntax of defining a namespace? 

a. namespace name{} 

b. Namespace name{}; 

c. namespace name{}; 

d. typedef namespace name{} NAME 


Answer- namespace name{} 


Que- To where does the program control transfers when the exception is arisen? 

a. catch 

b. handlers 

c. throw 

d. try 


Answer- handlers 


Que- Which keyword is used to check exception in the block of code? 

a. catch 

b. throw 

c. try 

d. handlers 


Answer- try 


Que- What will happen when the exception is not caught in the program? 

a. error 

b. program will execute 

c. block of that code will not execute 

d. program will execute & displays wrong output 


Answer- error 


Que- What will happen when the handler is not found for an exception? 

a. calls the standard library function terminate() 

b. raise an error 

c. executes the remaining block 

d. raise an error and executes the remaining block 


Answer- calls the standard library function terminate() 


Que- How many types of linkages are there in C++? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- To use internal linkage we have to use which keyword? 

a. static 

b. extern 

c. static or extern 

d. public 


Answer- static 


Que- Which one is used to refer to program elements in any translation units? 

a. internal linkage 

b. external linkage 

c. no linkage 

d. internal & external linkage 


Answer- external linkage 


Que- What is the default type of linkage that is available for identifiers? 

a. internal 

b. external 

c. no linkage 

d. single linkage 


Answer- external 


Que- To use external linkage we have to use which keyword? 

a. static 

b. extern 

c. const 

d. argc 


Answer- extern 


Que- Which is used to use a function from one source file to another? 

a. code 

b. declaration 

c. prototype 

d. variable 


Answer- prototype 


Que- What is the use of no linkage? 

a. make the entity visible to other programs 

b. make the entity visible to other blocks in the same program 

c. make the entity visible only to that block 

d. make the entity invisible 


Answer- make the entity visible only to that block 


Que- What is the user-defined header file extension in c++? 

a. cpp 

b. h 

c. hf 

d. hg 


Answer- h 


Que- Which of the following keyword is used to declare the header file? 

a. include 

b. exclude 

c. string 

d. namespace 


Answer- include 


Que- Identify the incorrect statement. 

a. iostream is a standard header and iostream.h is a non-standard header 

b. iostream is a non-standard header and iostream.h is a non-standard header 

c. iostream is a standard header and iostream.h is a standard header 

d. iostream is a non-standard header 


Answer- iostream is a standard header and iostream.h is a non-standard header 


Que- What does a default header file contain? 

a. prototype 

b. implementation 

c. declarations 

d. pointing 


Answer- declarations 


Que- setprecision requires which of the following header file? 

a. stdlib.h 

b. iomanip.h 

c. console.h 

d. conio.h 


Answer- iomanip.h 


Que- Which of the following header file does not exist? 

a. <iostream> 

b. <string> 

c. <sstring> 

d. <sstream> 


Answer- <sstring> 


Que- Which of the header file must be included to use stringstream? 

a. <iostream> 

b. <string> 

c. <sstring> 

d. <sstream> 


Answer- <string> 


Que- Which of the following header files is required for creating and reading data files? 

a. ofstream.h 

b. fstream.h 

c. ifstream.h 

d. console.h 


Answer- fstream.h 


Que- What does a class in C++ holds? 

a. data 

b. functions 

c. both data & functions 

d. arrays 


Answer- both data & functions 


Que- How many specifiers are present in access specifiers in class? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- Which is used to define the member of a class externally? 

a. : 

b. :: 

c. # 

d. !!$ 


Answer- :: 


Que- Which other keywords are also used to declare the class other than class? 

a. struct 

b. union 

c. object 

d. both struct & union 


Answer- both struct & union 


Que- Which of the following is a valid class declaration? 

a. class A { int x; }; 

b. class B { } 

c. public class A { } 

d. object A { int x; }; 


Answer- class A { int x; }; 


Que- The data members and functions of a class in C++ are by default ____________ 

a. protected 

b. private 

c. public 

d. public & protected 


Answer- private 


Que- Constructors are used to ____________ 

a. initialize the objects 

b. construct the data members 

c. both initialize the objects & construct the data members 

d. delete the objects 


Answer- initialize the objects 


Que- When struct is used instead of the keyword class means, what will happen in the program? 

a. access is public by default 

b. access is private by default 

c. access is protected by default 

d. access is denied 


Answer- access is public by default 


Que- Which category of data type a class belongs to? 

a. Fundamental data type 

b. Derived data type 

c. User defined derived data type 

d. Atomic data type 


Answer- User defined derived data type 


Que- Which operator a pointer object of a class uses to access its data members and member functions? 

a. . 

b. -> 

c. : 

d. :: 


Answer- -> 


Que- How the objects are self-referenced in a member function of that class. 

a. Using a special keyword object 

b. Using this pointer 

c. Using * with the name of that object 

d. By passing self as a parameter in the member function 


Answer- Using this pointer 


Que- What does a mutable member of a class mean? 

a. A member that can never be changed 

b. A member that can be updated only if it not a member of constant object 

c. A member that can be updated even if it a member of constant object 

d. A member that is global throughout the class 


Answer- A member that can be updated even if it a member of constant object 


Que- Pick the incorrect statement about inline functions in C++? 

a. They reduce function call overheads 

b. These functions are inserted/substituted at the point of call 

c. Saves overhead of a return call from a function 

d. They are generally very large and complicated function 


Answer- They are generally very large and complicated function 


Que- Inline functions are avoided when ____________________________ 

a. function contains static variables 

b. function have recursive calls 

c. function have loops 

d. all of the mentioned 


Answer- all of the mentioned 


Que- Pick the correct statement. 

a. Macros and inline functions are same thing 

b. Macros looks like function calls but they are actually not 

c. Inline functions looks like function but they are not 

d. Inline function are always large 


Answer- Macros looks like function calls but they are actually not 


Que- Which keyword is used to define the user defined data types? 

a. def 

b. union 

c. typedef 

d. type 


Answer- typedef 


Que- Identify the correct statement. 

a. typedef does not create different types. It only creates synonyms of existing types 

b. typedef create different types 

c. typedef create own types 

d. typedef will not creates synonyms of existing types 


Answer- typedef does not create different types. It only creates synonyms of existing types 


Que- What does the data type defined by union will do? 

a. It allow one different portion of memory to be accessed as same data types 

b. It allow one same portion of memory to be accessed as same data types 

c. It allow one different portion of memory to be accessed as different data types 

d. It allow one same portion of memory to be accessed as different data types 


Answer- It allow one same portion of memory to be accessed as different data types 


Que- What is the syntax of user-defined data types? 

a. typedef ExistingDataType NameByUser 

b. typedef NameByUser ExistingDataType 

c. def NameByUser ExistingDataType 

d. def NameByUser ExistingData 


Answer- typedef ExistingDataType NameByUser 


Que- How many types of user-defined data type are in c++? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- What is the scope of typedef defined data types? 

a. inside that block only 

b. whole program 

c. outside the program 

d. main function 


Answer- whole program 


Que- How many types of models are available to create the user-defined data type? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2

Previous Post Next Post