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

C++ Programming MCQ (Multiple Choice Questions)

Que- How a reference is different from a pointer? 

a. A reference cannot be null 

b. A reference once established cannot be changed 

c. The reference doesn't need an explicit dereferencing mechanism 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which of the following statement(s) is/are correct? 

a. * operator is used to declare a reference 

b. A reference variable defined to refer a particular variable can refer to any other variable also 

c. References must always be initialized inside classes 

d. A variable can have more than one references 


Answer- A variable can have more than one references 


Que- The void pointer can point to which type of objects? 

a. int 

b. float 

c. double 

d. all of the mentioned 


Answer- all of the mentioned 


Que- When does the void pointer can be dereferenced? 

a. when it doesn't point to any value 

b. when it cast to another type of object 

c. using delete keyword 

d. using shift keyword 


Answer- when it cast to another type of object 


Que- The pointer can point to any variable that is not declared with which of these? 

a. const 

b. volatile 

c. both const & volatile 

d. static 


Answer- both const & volatile 


Que- A void pointer cannot point to which of these? 

a. methods in c++ 

b. class member in c++ 

c. methods & class member in c++ 

d. none of the mentioned 


Answer- none of the mentioned 


Que- What we can't do on a void pointer? 

a. pointer arithmetic 

b. pointer functions 

c. pointer objects 

d. pointer functions & objects 


Answer- pointer arithmetic 


Que- The data elements in the structure are also known as what? 

a. objects 

b. members 

c. data 

d. objects & data 


Answer- members 


Que- What will be used when terminating a structure? 

a. : 

b. } 

c. ; 

d. ;; 


Answer- ; 


Que- What will happen when the structure is declared? 

a. it will not allocate any memory 

b. it will allocate the memory 

c. it will be declared and initialized 

d. it will be declared 


Answer- it will not allocate any memory 


Que- The declaration of the structure is also called as? 

a. structure creator 

b. structure signifier 

c. structure specifier 

d. structure creator & signifier 


Answer- structure specifier 


Que- Which of the following is a properly defined structure? 

a. struct {int a;} 

b. struct a_struct {int a;} 

c. struct a_struct int a; 

d. struct a_struct {int a;}; 


Answer- struct a_struct {int a;}; 


Que- Which of the following accesses a variable in structure *b? 

a. b->var; 

b. b.var; 

c. b-var; 

d. b>var; 


Answer- b->var; 


Que- Which function is used to check whether a character is an alphabet? 

a. isalpha() 

b. isalnum() 

c. isdigit() 

d. isblank() 


Answer- isalpha() 


Que- Which function is used to check whether a character is an alphabet or number? 

a. isalpha() 

b. isalnum() 

c. isdigit() 

d. isblank() 


Answer- isalnum() 


Que- Which function is used to check whether a character is a number? 

a. isalpha() 

b. isalnum() 

c. isdigit() 

d. isblank() 


Answer- isdigit() 


Que- Which function is used to check whether a character is a tab or space? 

a. isalpha() 

b. isalnum() 

c. isdigit() 

d. isblank() 


Answer- isblank() 


Que- Which function is used to check whether a character is tab or a control code? 

a. isspace() 

b. isalnum() 

c. iscntrl() 

d. isblank() 


Answer- iscntrl() 


Que- Which function is used to check whether a character is printable on console? 

a. isxdigit() 

b. isprint() 

c. iscntrl() 

d. ispunct() 


Answer- isprint() 


Que- Which function is used to check whether a character is hexadecimal? 

a. isxdigit() 

b. isprint() 

c. iscntrl() 

d. ispunct() 


Answer- isxdigit() 


Que- Which function is used to check whether a character is punctuation mark? 

a. isxdigit() 

b. isprint() 

c. iscntrl() 

d. ispunct() 


Answer- ispunct() 


Que- Which operator is having the right to left associativity in the following? 

a. Array subscripting 

b. Function call 

c. Addition and subtraction 

d. Type cast 


Answer- Type cast 


Que- Which operator is having the highest precedence? 

a. postfix 

b. unary 

c. shift 

d. equality 


Answer- postfix 


Que- What is this operator called ?:? 

a. conditional 

b. relational 

c. casting operator 

d. unrelational 


Answer- conditional 


Que- What is the use of dynamic_cast operator? 

a. it converts virtual base class to derived class 

b. it converts the virtual base object to derived objects 

c. it will convert the operator based on precedence 

d. it converts the virtual base object to derived class 


Answer- it converts virtual base class to derived class 


Que- How are many sequences of statements present in c++? 

a. 4 

b. 3 

c. 5 

d. 6 


Answer- 5 


Que- The if..else statement can be replaced by which operator? 

a. Bitwise operator 

b. Conditional operator 

c. Multiplicative operator 

d. Addition operator 


Answer- Conditional operator 


Que- The switch statement is also called as? 

a. choosing structure 

b. selective structure 

c. certain structure 

d. bitwise structure 


Answer- selective structure 


Que- The destination statement for the goto label is identified by what label? 

a. $ 

b. @ 

c. * 

d. : 


Answer- : 


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

a. 4 

b. 2 

c. 3 

d. 1 


Answer- 4 


Que- Which looping process is best used when the number of iterations is known? 

a. for 

b. while 

c. do-while 

d. all looping processes require that the iterations be known 


Answer- for 


Que- How many types of comments are there in c++? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- What is a comment in c++? 

a. comments are parts of the source code disregarded by the compiler 

b. comments are executed by the compiler to find the meaning of the comment 

c. comments are executable 

d. comments are executed by the compiler 


Answer- comments are parts of the source code disregarded by the compiler 


Que- What type of comments does c++ support? 

a. single line 

b. multiline 

c. single line and multi-line 

d. reusable line 


Answer- single line and multi-line 


Que- What is used to write multi line comment in c++? 

a. /* …. */ 

b. /$ …. $/ 

c. // 

d. /$ …. */ 


Answer- /* …. */ 


Que- What is the use of the indentation in c++? 

a. distinguishes between comments and code 

b. r distinguishes between comments and outer data 

c. distinguishes between comments and outer data 

d. r distinguishes between comments and inner data 


Answer- distinguishes between comments and code 


Que- Where does the execution of the program starts? 

a. user-defined function 

b. main function 

c. void function 

d. else function 


Answer- main function 


Que- What are mandatory parts in the function declaration? 

a. return type, function name 

b. return type, function name, parameters 

c. parameters, function name 

d. parameters, variables 


Answer- return type, function name 


Que- which of the following is used to terminate the function declaration? 

a. : 

b. ) 

c. ; 

d. ] 


Answer- ; 


Que- How many can max number of arguments present in function in the c99 compiler? 

a. 99 

b. 90 

c. 102 

d. 127 


Answer- 127 


Que- Which is more effective while calling the functions? 

a. call by value 

b. call by reference 

c. call by pointer 

d. call by object 


Answer- call by reference 


Que- What is the scope of the variable declared in the user defined function? 

a. whole program 

b. only inside the {} block 

c. the main function 

d. header section 


Answer- only inside the {} block 


Que- How many minimum number of functions should be present in a C++ program for its execution? 

a. 0 

b. 1 

c. 2 

d. 3 


Answer- 1 


Que- Which of the following is the default return value of functions in C++? 

a. int 

b. char 

c. float 

d. void 


Answer- int 


Que- What happens to a function defined inside a class without any complex operations (like looping, a large number of lines, etc)? 

a. It becomes a virtual function of the class 

b. It becomes a default calling function of the class 

c. It becomes an inline function of the class 

d. The program gives an error 


Answer- It becomes an inline function of the class 


Que- What is an inline function? 

a. A function that is expanded at each call during execution 

b. A function that is called during compile time 

c. A function that is not checked for syntax errors 

d. A function that is not checked for semantic analysis 


Answer- A function that is expanded at each call during execution 


Que- An inline function is expanded during ______________ 

a. compile-time 

b. run-time 

c. never expanded 

d. end of the program 


Answer- run-time 


Que- In which of the following cases inline functions may not word? i) If the function has static variables. ii) If the function has global and register variables. iii) If the function contains loops iv) If the function is recursive 

a. i, iv 

b. iii, iv 

c. ii, iii, iv 

d. i, iii, iv 


Answer- i, iii, iv 


Que- When we define the default values for a function? 

a. When a function is defined 

b. When a function is declared 

c. When the scope of the function is over 

d. When a function is called 


Answer- When a function is declared 


Que- Where should default parameters appear in a function prototype? 

a. To the rightmost side of the parameter list 

b. To the leftmost side of the parameter list 

c. Anywhere inside the parameter list 

d. Middle of the parameter list 


Answer- To the rightmost side of the parameter list

Previous Post Next Post