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

C++ Programming MCQ (Multiple Choice Questions)

 Que- How to store the large objects in c++ if it extends its allocated memory? 

a. memory heap 

b. stack 

c. queue 

d. stack & queue 


Answer- memory heap 


Que- When we are using heap operations what do we need to do to save the memory? 

a. rename the objects 

b. delete the objects after processing 

c. both rename & delete the objects 

d. add the objects 


Answer- delete the objects after processing 


Que- Which container in c++ will take large objects? 

a. string 

b. class 

c. vector 

d. string & class 


Answer- vector 


Que- How to stop your program from eating so much ram? 

a. Find a way to work with the data one at a time 

b. Declare it in program memory, instead of on the stack 

c. Use the hard drive, instead of RAM 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which option is best to eliminate the memory problem? 

a. use smart pointers 

b. use raw pointers 

c. use virtual destructor 

d. use smart pointers & virtual destructor 


Answer- use smart pointers & virtual destructor 


Que- What is the size of the heap? 

a. 10MB 

b. 500MB 

c. 1GB 

d. Size of the heap memory is limited by the size of the RAM and the swap memory 


Answer- Size of the heap memory is limited by the size of the RAM and the swap memory 


Que- How to unlimit the size of the stack? 

a. setrlimit() 

b. unlimit() 

c. both setrlimit() & unlimit() 

d. setflimit() 


Answer- setrlimit() 


Que- In Linux, how do the heaps and stacks are managed? 

a. ram 

b. secondary memory 

c. virtual memory 

d. static memory 


Answer- virtual memory 


Que- Which is used to pass the large objects in c++? 

a. pass by value 

b. pass by reference 

c. both pass by value & reference 

d. pass by name 


Answer- pass by reference 


Que- In which direction does the assignment operation will take place? 

a. left to right 

b. right to left 

c. top to bottom 

d. bottom to top 


Answer- right to left 


Que- Pick out the compound assignment statement. 

a. a = a – 5 

b. a = a / b 

c. a -= 5 

d. a = a + 5 


Answer- a -= 5 


Que- What is the associativity of add(+);? 

a. right to left 

b. left to right 

c. right to left & left to right 

d. top to bottom 


Answer- left to right 


Que- Which operator is having the highest precedence in c++? 

a. array subscript 

b. Scope resolution operator 

c. static_cast 

d. dynamic_cast 


Answer- Scope resolution operator 


Que- subscript operator is used to access which elements? 

a. string 

b. char 

c. array 

d. float 


Answer- array 


Que- How many arguments will the subscript operator will take for overloading? 

a. 1 

b. 2 

c. 0 

d. as many as possible 


Answer- 1 


Que- Pick out the correct statement. 

a. subscript operator has a higher precedence than the assignment operator 

b. subscript operator has a lower precedence than the assignment operator 

c. subscript operator is used with string elements 

d. subscript operator is used with char elements 


Answer- subscript operator has a higher precedence than the assignment operator 


Que- What do we need to do to pointer for overloading the subscript operator? 

a. reference pointer 

b. dereference pointer 

c. store it in heap 

d. memory locator 


Answer- dereference pointer 


Que- What do we need to use when we have multiple subscripts? 

a. operator() 

b. operator[] 

c. operator 

d. operator<> 


Answer- operator() 


Que- What is the use of function call operator? 

a. overloading the methods 

b. overloading the objects 

c. overloading the parameters 

d. overloading the string 


Answer- overloading the objects 


Que- Pick out the correct statement. 

a. virtual functions does not give the ability to write a templated function 

b. virtual functions does not give the ability to rewrite a templated function 

c. virtual functions does give the ability to write a templated function 

d. virtual functions does not give the ability to rewrite a simple function 


Answer- virtual functions does not give the ability to write a templated function 


Que- What is the use of functor? 

a. It makes the object "callable" like a function 

b. It makes the class "callable" like a function 

c. It makes the attribute "callable" like a function 

d. It makes the argument "callable" like a function 


Answer- It makes the object "callable" like a function 


Que- Which is used to tell the computer that where a pointer is pointing to? 

a. dereference 

b. reference 

c. heap operations 

d. binary operations 


Answer- dereference 


Que- Which is used to do the dereferencing? 

a. pointer without asterix 

b. value without asterix 

c. pointer with asterix 

d. value with asterix 


Answer- pointer with asterix 


Que- Pick out the correct option. 

a. References automatically dereference without needing an extra character 

b. References automatically dereference with an extra character 

c. Reference will not dereference 

d. Reference automatically dereference with extra space and character 


Answer- References automatically dereference without needing an extra character 


Que- What does the dereference operator will return? 

a. rvalue equivalent to the value at the pointer address 

b. lvalue equivalent to the value at the pointer address 

c. it will return nothing 

d. it will return boolean values 


Answer- lvalue equivalent to the value at the pointer address 


Que- Pick out the correct statement. 

a. the null pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to null 

b. the null pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to the memory address 

c. rvalue equivalent to the value at the pointer address 

d. null pointer will not return anything 


Answer- the null pointer dereference occurs where a pointer that is expected to be a valid address but instead is equal to null 


Que- Which operator works only with integer variables? 

a. increment 

b. decrement 

c. both increment & decrement 

d. binary operator 


Answer- both increment & decrement 


Que- How many types are there in increment/decrement operator? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- Pick out the correct statement. 

a. Increment operator ++ adds 1 to its operand 

b. Increment operator ++ adds 2 to its operand 

c. Decrement operator ++ subtracts 1 to its operand 

d. Decrement operator ++ subtracts 3 to its operand 


Answer- Increment operator ++ adds 1 to its operand 


Que- Pick out the correct statement. 

a. Pre Increment is faster than post-increment 

b. post-increment is faster than Pre Increment 

c. pre increment is slower than post-increment 

d. pre decrement is slower than post-increment 


Answer- Pre Increment is faster than post-increment 


Que- Which concepts does the Pre Increment use? 

a. call by value 

b. call by reference 

c. queue 

d. call by name 


Answer- call by reference 


Que- How many types of representation are in the string? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- What is the header file for the string class? 

a. #include<ios> 

b. #include<str> 

c. #include<string> 

d. #include<stio> 


Answer- #include<string> 


Que- Which is used to return the number of characters in the string? 

a. length 

b. size 

c. both size & length 

d. name 


Answer- both size & length 


Que- Which method do we use to append more than one character at a time? 

a. append 

b. operator+= 

c. data 

d. both append & operator+= 


Answer- both append & operator+= 


Que- What is string objects in C++? 

a. Stream of alphabets 

b. A stream of well-defined characters 

c. Stream of characters 

d. A stream of characters terminated by 


Answer- A stream of well-defined characters 


Que- What is Character-Array? 

a. array of alphabets 

b. array of well-defined characters 

c. array of characters 

d. array of characters terminated by 


Answer- array of characters 


Que- Pick the incorrect statement about Character-Array. 

a. Character-Array can be terminated by a null character(' 

b. 0') 

c. Character-Array has a static size 

d. Character-Array has a dynamic size 


Answer- Character-Array has a static size 


Que- Pick the correct statement about string objects in C++. 

a. String objects must be terminated by a null character(' 

b. 0') 

c. String objects have a static size 

d. String objects have a dynamic size 


Answer- String objects have a static size 


Que- Which of the following is not a modifier function in string class? 

a. operator+=() 

b. operator[]() 

c. push_back() 

d. erase() 


Answer- operator[]() 


Que- Which function is used to get the length of a string object? 

a. str.length() 

b. str.size() 

c. str.max_size() 

d. both size() and length() function 


Answer- both size() and length() function

Previous Post Next Post