InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What is linear_congruential_engine?(a) Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using Mersenne Twister algorithm(b) Pseudo-random number engine that generates random unsigned integers(c) Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using lagged Fibonacci generator(d) Pseudo-random number engine that generates random signed integers in the range [0, 2^w-1] for some w using Mersenne Twister algorithm |
|
Answer» Correct answer is (b) Pseudo-random number engine that generates random unsigned integers For explanation: linear_congruential_engine is a simple Pseudo-random number engine that generates random unsigned integer using the basic algorithm. |
|
| 2. |
Which function is used to get the real part of the complex number?(a) img_p()(b) imag_p()(c) real()(d) real_p() |
|
Answer» Correct option is (c) real() Best explanation: The real() function is provided by the complex |
|
| 3. |
Which function is used to get the argument of a complex number?(a) abs()(b) norm()(c) arg()(d) argu() |
|
Answer» Right answer is (c) arg() The best I can explain: The argument of a complex is calculated using the arg() function of the |
|
| 4. |
Which of the following is correct about extent() function?(a) Returns how many elements are in array currently(b) Returns the size of the 1st dimension(c) Returns how many total elements can be stored in an array(d) Returns the size of a given dimension |
|
Answer» The correct choice is (d) Returns the size of a given dimension Best explanation: The extent() function takes two parameters one denoting the array other showing the dimension for which the size we want to know. |
|
| 5. |
What is subtract_with_carry_engine?(a) Pseudo-random number engine that generates random unsigned integers(b) Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using Mersenne Twister algorithm(c) Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using lagged Fibonacci generator(d) Pseudo-random number engine that generates random signed integers in the range [0, 2^w-1] for some w using Mersenne Twister algorithm |
|
Answer» Correct choice is (c) Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using lagged Fibonacci generator For explanation: subtract_with_carry_engine is a Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using lagged Fibonacci generator. |
|
| 6. |
What is vptr?(a) A hidden pointer in a class that points to a virtual table of that class(b) A hidden pointer in a class that points to virtual functions of that class(c) A hidden pointer in a class that points to virtual members of the class of that class(d) A pointer in a class that points to other class |
|
Answer» Correct answer is (a) A hidden pointer in a class that points to a virtual table of that class The best I can explain: vptr is a hidden pointer available with classes which are used to point to the virtual table of a class. |
|
| 7. |
Which function is used to calculate the conjugate of a complex number?(a) conj()(b) reverse()(c) opp()(d) find_conj() |
|
Answer» Correct choice is (a) conj() Easiest explanation - |
|
| 8. |
What is the use of is_array() function in C++?(a) To check if a variable is array type or not(b) To check if a variable is 1-D array type or not(c) To check if a variable is 2-D array type or not(d) To check if a variable is 1-D or 2-D array type or not |
|
Answer» The correct option is (a) To check if a variable is array type or not The best explanation: is_array() function is used to check whether a given variable is of array type or not. |
|
| 9. |
Which function is used to get the imaginary part of the complex number?(a) real()(b) imag()(c) imag_p()(d) real_p() |
|
Answer» Correct choice is (b) imag() To explain: The imag() function is provided by the complex |
|
| 10. |
What is the full form of vtable?(a) V type table(b) Vector table(c) Virtual table(d) Virtual-vector table |
|
Answer» Right answer is (c) Virtual table Easiest explanation - Full form of vtable is a virtual table. This is called so because it stores the information about virtual functions of a class. |
|
| 11. |
What is Pseudo-random number engines?(a) Uses user input for random number generation(b) Uses an algorithm that does not require any initial seed to generate random numbers(c) Uses initial seed based algorithm to generate random numbers(d) Random number generates depends on the program |
|
Answer» Correct option is (c) Uses initial seed based algorithm to generate random numbers To explain I would say: Pseudo-random number engines are used to generate random numbers based on an initial seed provided to them. |
|
| 12. |
Which is used for manually writing lookup table?(a) std:map(b) std:lookup(c) std:find(d) std:lock |
|
Answer» Correct answer is (a) std:map Explanation: Lookup table means storing values in a table with unique keys for each value so that can be checked in future easily. So for such lookup tables maps are used in C++. |
|
| 13. |
How many sets of requirements are need in designing a container?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» Correct option is (c) 3 Easiest explanation - There are three sets of requirements. They are container interface requirements, Allocator interface requirements and iterator requirements. |
|
| 14. |
Which of the following type does the container should define?(a) Iterator type(b) Vector type(c) Storage type(d) Memory type |
|
Answer» The correct option is (a) Iterator type Explanation: Every container must define an iterator type. Iterators allow algorithms to iterate over the container’s contents. |
|
| 15. |
What is the use of is_same() function in C++?(a) To check if a variable is array type or not(b) To check whether two variables have the same characteristics(c) To check if two variable is of array type or not(d) To check whether two variables are different or not |
|
Answer» Right choice is (b) To check whether two variables have the same characteristics Explanation: is_same() function is used to check whether two variables have the same characteristics or not. |
|
| 16. |
Which of the following is correct about remove_extent() function?(a) Removes the given dimension from an array(b) Removes the first dimension from the right of the array(c) Removes the first dimension from the left of the array(d) Removes the last dimension from the left of the array |
|
Answer» Right answer is (c) Removes the first dimension from the left of the array For explanation: remove_extent() function removes the first dimension i.e. the first dimension from the given array. |
|
| 17. |
Which of the header file is used for array type manipulation?(a) (b) (c) (d) std namespace |
|
Answer» Right answer is (d) std namespace Best explanation: Array type manipulation functions are declared incside the namespace std so you can use namespace std to use these functions. |
|
| 18. |
What is the full form of vptr?(a) Vector Pointer(b) Virtual Pointer(c) V type Pointer(d) Virtual-vector Pointer |
|
Answer» Correct answer is (a) Vector Pointer To explain: vptr is abbreviated for a virtual pointer which is used to point virtual tables of a class. |
|
| 19. |
What do container adapter provide to interface?(a) Restricted interface(b) More interface(c) No interface(d) Memory interface |
|
Answer» Right option is (a) Restricted interface To explain: A container adapter provides a restricted interface to a container.In particular, adapters do not provide iterators; they are intended to be used only through their specialized interfaces. |
|
| 20. |
In which context does the stack operates?(a) FIFO(b) LIFO(c) Both FIFO & LIFO(d) LIFI |
|
Answer» Right choice is (b) LIFO Easiest explanation - A stack is a container where elements operate in a LIFO context, where elements are inserted (pushed) and removed (popped) from the end of the container. |
|
| 21. |
How can the member functions in the container be accessed?(a) Iterator(b) Indirect(c) Both Iterator & Indirect(d) Vector |
|
Answer» The correct option is (a) Iterator The best explanation: The container manages the storage space for its elements and provides member functions to access them, either directly or through iterators which reference objects with similar properties to pointers. |
|
| 22. |
What is vtable in C++?(a) Lookup table to resolve function calls in dynamic manners(b) Lookup table to resolve function calls in static manners(c) Lookup table to see which are the functions available for calls throughout the program(d) Lookup table to check how many functions are there int he program |
|
Answer» Correct option is (a) Lookup table to resolve function calls in dynamic manners The explanation: vtable is a lookup table that is used to resolve the function calls in dynamic/late binding manners. |
|
| 23. |
What are different operations are used in Pseudo-random number engines?(a) operator()(b) min()(c) max()(d) all of the mentioned |
|
Answer» Correct choice is (d) all of the mentioned Easy explanation - Pseudo-random number engines use three operations operator() that generates a random number, min() that returns minimum value returned by member operator() and max() returns the maximum value. |
|
| 24. |
Which header file is used for generating random numbers?(a) (b) (c) (d) |
|
Answer» The correct answer is (d) Easiest explanation - |
|
| 25. |
What is a Random number generator?(a) A generator that generates deterministic random numbers(b) A generator that generates both non-deterministic random numbers and deterministic random numbers(c) A generator that generates non-deterministic random numbers(d) A generator that generates a simple random number |
|
Answer» Correct option is (c) A generator that generates non-deterministic random numbers Best explanation: Random number generator is a random number generator which generates non-deterministic random numbers. |
|
| 26. |
How many Pseudo-random number engines are there?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» Right answer is (c) 3 To explain: There are three types of Pseudo-random number engines based on the algorithm they use. They are linear_congruential_engine, mersenne_twister_engine and subtract_with_carry_engine. |
|
| 27. |
To which of the following access specifiers are applicable?(a) Member data(b) Functions(c) Both Member data & Functions(d) Protected members |
|
Answer» Right answer is (c) Both Member data & Functions To explain I would say: The access specifiers can be applicable to the member data and functions because they need to be accessed outside the block. |
|
| 28. |
What does the sequence adaptor provide?(a) Insertion(b) Deletion(c) Interface to sequence container(d) Insertion & Deletion |
|
Answer» Correct answer is (c) Interface to sequence container To explain: Sequence adaptor provides interface to sequence container. |
|
| 29. |
Which operators are used in the free store?(a) new(b) delete(c) both new & delete(d) terminate |
|
Answer» Correct answer is (c) both new & delete The best I can explain: new and delete operators are used to allocate and deallocate the memory for the program. |
|
| 30. |
Which is used to allocate and deallocate storage for objects during the execution?(a) Stack(b) Heap(c) Freestore(d) Queue |
|
Answer» The correct option is (c) Freestore Easy explanation - Free store is a pool of memory available for you to allocate and deallocate storage for objects during the execution of your program. |
|
| 31. |
What type of class member is operator new?(a) static(b) dynamic(c) const(d) smart |
|
Answer» Correct answer is (a) static Explanation: static is a type of class member is operator new. |
|
| 32. |
Which header file is required to use complex class in your program?(a) (b) (c) (d) |
|
Answer» The correct answer is (a) Easiest explanation - |
|
| 33. |
What are Engine Adaptors?(a) Class template that adopts a pseudo-random number generator engine(b) Class template that adopts a pseudo-random number generator engine to produce numbers with a given numbers of bits(c) Random number engine that generates pseudo-random numbers(d) Mersenne Twister 19937 generator generating 32-bit true random number |
|
Answer» Right answer is (b) Class template that adopts a pseudo-random number generator engine to produce numbers with a given numbers of bits Easy explanation - Engine adaptor is a class template that adapts a pseudo-random number generator to produce random number having a specific number of bits. |
|
| 34. |
What is the default random engine?(a) Random number engine that generates pseudo-random numbers(b) Mersenne Twister 19937 generator generating 32-bit true random number(c) Random number engine that generates true random numbers(d) Mersenne Twister 19937 generator generating 32-bit pseudo random number |
|
Answer» The correct choice is (a) Random number engine that generates pseudo-random numbers Explanation: Default random engine is a random number engine that generates pseudo random numbers. |
|
| 35. |
Pick out the wrong header file about strings.(a) (b) (c) (d) |
|
Answer» Right option is (c) For explanation: The standard header files for string is string and regex. So the wrong one presented here is ios. |
|
| 36. |
What is random_device?(a) A pseudo-random number generator(b) Time-dependent random number generator(c) Simple random number generator(d) A true random number generator |
|
Answer» The correct option is (d) A true random number generator Explanation: random_device is a true random number generator not the pseudo random number generator. |
|
| 37. |
Which is best for coding the standard library for c++?(a) no trailing underscores on names(b) complex objects are returned by value(c) have a member-swap()(d) all of the mentioned |
|
Answer» Right choice is (d) all of the mentioned The best explanation: Best coding for the standard library for c++ is: -> No trailing underscores on names -> Complex objects are returned by value -> It should have a member-swap(). |
|
| 38. |
What is mersenne_twister_engine?(a) Pseudo-random number engine that generates random unsigned integers(b) Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using Mersenne Twister algorithm(c) Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using lagged Fibonacci generator(d) Pseudo-random number engine that generates random signed integers in the range [0, 2^w-1] for some w using Mersenne Twister algorithm |
|
Answer» Correct option is (b) Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using Mersenne Twister algorithm The best explanation: mersenne_twister_engine is a Pseudo-random number engine that generates random unsigned integers in the range [0, 2^w-1] for some w using Mersenne Twister algorithm. |
|
| 39. |
What is meant by standard c++ library?(a) It is the collection of class definitions for standard data structures and a collection of algorithms(b) It is a header file(c) Collection of algorithms(d) Step by step process |
|
Answer» Correct option is (a) It is the collection of class definitions for standard data structures and a collection of algorithms Explanation: It is the collection of class definitions for standard data structures. This part of the library was derived from the Standard Template Library. |
|
| 40. |
Which of the following is corect way of constructing bitset using integer number?(a) bitset b;(b) bitset b(12);(c) bitset b(string(“1100”));(d) bitset b(float(12)); |
|
Answer» The correct choice is (b) bitset Best explanation: The correct way of constructing bitset using integer number is as follows: bitset |
|
| 41. |
Indexing of bitset variables starts from ___________(a) leftmost bit(b) rightmost bit(c) same as in an array(d) front |
|
Answer» Right option is (b) rightmost bit The explanation: The indexing of bitset variable starts from rightmost bit i.e. if you have b = 1100 as your bitset then b[0] = 0, not 1. |
|
| 42. |
What is the use of the set() function in bitset?(a) Used to make alternate bits zero(b) Used to make a bit 0 in a bitset(c) Used to make all bits zero(d) Used to set bit(s) in a bitset |
|
Answer» Correct choice is (d) Used to set bit(s) in a bitset The explanation: |
|
| 43. |
What must be an operand of operator delete?(a) Pointer(b) Array(c) Stack(d) Queue |
|
Answer» Correct option is (a) Pointer Easiest explanation - The operand of delete must be a pointer returned by new. |
|
| 44. |
Which of the following is correct about any() function in bitset?(a) Returns true if the number of 1’s equal to the number of 0’s(b) Returns true if any bit is set 0(c) Returns true if any bit is set 1(d) Returns true only if all bits are 1 |
|
Answer» The correct choice is (c) Returns true if any bit is set 1 The best explanation: |
|
| 45. |
What is the use of proj() function?(a) Used to calculate the argument of a complex number(b) Used to calculate the conjugate of a complex number(c) Used to calculate the negative of a complex number(d) Used to calculate the projection of a complex number |
|
Answer» Correct choice is (d) Used to calculate the projection of a complex number The best explanation: |
|
| 46. |
Which of the following is correct about none() function in bitset?(a) Returns true if any bits is set 1(b) Returns true if all bits is set 0(c) Returns true if the number of 1’s equal to the number of 0’s(d) Returns true only if all bits are 1 |
|
Answer» Correct choice is (b) Returns true if all bits is set 0 Easiest explanation - |
|
| 47. |
Pick out parameter for rehash method in unordered_set in c++?(a) count(b) size(c) hash(d) type |
|
Answer» Correct option is (a) count To explain I would say: count is used to return the new number of buckets. |
|
| 48. |
What are the Generators in C++?(a) An object that generates uniformly distributed numbers(b) An object that generates a number from a given sequence(c) An object that generates the smallest number from a given range(d) An object that generates unique numbers |
|
Answer» Right option is (a) An object that generates uniformly distributed numbers The explanation: Generators are objects that generates uniformly distributed numbers which help in generating random numbers. |
|
| 49. |
Which of the following is corect way of constructing bitset using binary string?(a) bitset b;(b) bitset b(12);(c) bitset b(string(“1100”));(d) bitset b(float(12)); |
|
Answer» Correct option is (c) bitset Explanation: The correct way of constructing bitset using binary string is as follows: bitset |
|
| 50. |
How many ways are there for constructing a bitset?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» Right choice is (c) 3 For explanation: There are three ways of constructing a bitset. Direct construction, using integer number and using binary string. |
|