InterviewSolution
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.
| 51. |
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 destructorThis question was addressed to me in an interview.This key question is from Large Objects in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» RIGHT OPTION is (d) USE smart POINTERS & virtual destructor Explanation: Virtual destructor means is that the object is destructed in reverse order in which it was constructed and the smart pointer will delete the object from memory when the object goes out of scope. |
|
| 52. |
Which rule will not affect the friend function?(a) private and protected members of a class cannot be accessed from outside(b) private and protected member can be accessed anywhere(c) protected member can be accessed anywhere(d) private member can be accessed anywhereThis question was posed to me by my school principal while I was bunking the class.Enquiry is from Friends topic in section Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Right OPTION is (a) private and protected members of a CLASS cannot be ACCESSED from outside |
|
| 53. |
How to access the object in the class?(a) scope resolution operator(b) ternary operator(c) direct member access operator(d) resolution operatorThis question was posed to me at a job interview.This intriguing question originated from Objects topic in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The CORRECT option is (C) DIRECT member access operator |
|
| 54. |
Which is used to use a function from one source file to another?(a) code(b) declaration(c) prototype(d) variableI have been asked this question in my homework.Question is taken from Linkage topic in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» RIGHT OPTION is (c) PROTOTYPE Explanation: By defining a function’s prototype in another file means, we can inherit all the FEATURES from the SOURCE function. |
|
| 55. |
In Linux, how do the heaps and stacks are managed?(a) ram(b) secondary memory(c) virtual memory(d) static memoryI got this question in an internship interview.This question is from Large Objects in portion Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The correct OPTION is (C) virtual memory |
|
| 56. |
Which container in c++ will take large objects?(a) string(b) class(c) vector(d) string & classI have been asked this question at a job interview.Origin of the question is Large Objects topic in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» CORRECT ANSWER is (c) vector To explain I would say: Because the vector is mainly used to STORE LARGE objects for the game programming and other operations etc. |
|
| 57. |
Which keyword is used to declare the friend function?(a) firend(b) friend(c) classfriend(d) myfriendThe question was asked in an online interview.This interesting question is from Friends in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Right OPTION is (B) FRIEND |
|
| 58. |
In case of non-static member functions how many maximum object arguments a binary operator overloaded function can take?(a) 1(b) 2(c) 3(d) 0I have been asked this question in final exam.My doubt is from Operator Overloading in portion Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The CORRECT answer is (a) 1 |
|
| 59. |
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 typeThis question was addressed to me in homework.The query is from Classes in portion Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The correct choice is (c) User defined DERIVED data type |
|
| 60. |
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; };This question was posed to me in a national level competition.This key question is from Classes topic in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The CORRECT OPTION is (a) class A { int x; }; |
|
| 61. |
Which of the following header file does not exist?(a) (b) (c) (d) I got this question in an online quiz.I would like to ask this question from Header Files Usage topic in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The CORRECT ANSWER is (C) |
|
| 62. |
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 \0I have been asked this question in an interview.The doubt is from String topic in portion Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» CORRECT answer is (b) A STREAM of well-defined characters To explain: String is defined as STREAMS of characters, not necessarily terminated by \0. Also, a string can contain characters other than ALPHABETS. |
|
| 63. |
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 valuesThe question was posed to me in exam.Asked question is from Dereferencing topic in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Right choice is (B) LVALUE EQUIVALENT to the VALUE at the pointer address |
|
| 64. |
How are types therein user-defined conversion?(a) 1(b) 2(c) 3(d) 4I got this question at a job interview.This intriguing question originated from Conversion Operators in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» CORRECT choice is (b) 2 The EXPLANATION is: There are TWO types of user-defined conversions. They are conversion by the CONSTRUCTOR, Conversion functions. |
|
| 65. |
Which of the following operator cannot be overloaded?(a) +(b) ?:(c) –(d) %The question was asked in semester exam.My question comes from Operator Overloading in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» CORRECT choice is (B) ?: To explain I would say: ?:, :: and . cannot be overloaded +, -, % can be overloaded. |
|
| 66. |
What is the syntax of user-defined data types?(a) typedef ExistingDataType NameByUser(b) typedef NameByUser ExistingDataType(c) def NameByUser ExistingDataType(d) def NameByUser ExistingDataThe question was asked in a national level competition.This interesting question is from User Defined Types in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Correct option is (a) TYPEDEF EXISTINGDATATYPE NameByUser |
|
| 67. |
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 functionI have been asked this question in a national level competition.This key question is from Classes in portion Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Correct answer is (d) They are generally very large and complicated function |
|
| 68. |
What is Character-Array?(a) array of alphabets(b) array of well-defined characters(c) array of characters(d) array of characters terminated by \0This question was posed to me in quiz.This question is from String in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» CORRECT ANSWER is (c) array of characters The best explanation: Character-Array is DEFINED as an array of characters, not NECESSARILY terminated by \0. Also, a character-array can CONTAIN characters other than alphabets. |
|
| 69. |
How many types are there in increment/decrement operator?(a) 1(b) 2(c) 3(d) 4I got this question in an internship interview.My doubt stems from Increment and Decrement in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Right answer is (b) 2 |
|
| 70. |
Why we use the “dynamic_cast” type conversion?(a) result of the type conversion is a valid(b) to be used in low memory(c) result of the type conversion is an invalid(d) it is used for storageI got this question by my college director while I was bunking the class.The question is from Conversion Operators in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Right answer is (a) RESULT of the type conversion is a valid |
|
| 71. |
What is the return type of the conversion operator?(a) void(b) int(c) float(d) no return typeThe question was posed to me in an interview for job.Enquiry is from Conversion Operators in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The CORRECT option is (d) no RETURN TYPE |
|
| 72. |
Where does the object is created?(a) class(b) constructor(c) destructor(d) attributesI got this question during an interview.Question is taken from Objects in section Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Correct CHOICE is (a) CLASS |
|
| 73. |
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 classI have been asked this question during an interview.This key question is from Classes in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» CORRECT answer is (C) A MEMBER that can be updated even if it a member of CONSTANT OBJECT For explanation: Mutable members are those which can be updated even if it a member of a constant object. You can change their value even from a constant member function of that class. |
|
| 74. |
Which operator a pointer object of a class uses to access its data members and member functions?(a) .(b) ->(c) :(d) ::I have been asked this question during an interview.My query is from Classes topic in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Correct option is (B) -> |
|
| 75. |
What is the default type of linkage that is available for identifiers?(a) internal(b) external(c) no linkage(d) single linkageThe question was asked during an online interview.The query is from Linkage topic in portion Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The correct OPTION is (b) EXTERNAL |
|
| 76. |
Which header file is used to include the string object functions in C++?(a) #include (b) #include (c) #include (d) #include I got this question in an international level competition.My question is taken from String topic in section Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The CORRECT option is (C) #include |
|
| 77. |
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 locatorThe question was asked in an interview for internship.Question is from Subscripting topic in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» RIGHT OPTION is (b) dereference pointer Best explanation: If you have a pointer to an object of some class type that OVERLOADS the subscript operator, you have to dereference that pointer in ORDER to FREE the memory. |
|
| 78. |
Which of the following is correct about friend functions?(a) Friend functions use the dot operator to access members of a class using class objects(b) Friend functions can be private or public(c) Friend cannot access the members of the class directly(d) All of the mentionedThis question was posed to me during a job interview.The above asked question is from Friend Function topic in section Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Correct option is (d) All of the mentioned |
|
| 79. |
How many parameters does a conversion operator may take?(a) 0(b) 1(c) 2(d) as many as possibleThe question was asked in a national level competition.The question is from Conversion Operators in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The CORRECT CHOICE is (a) 0 |
|
| 80. |
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 operandI got this question by my college director while I was bunking the class.Asked question is from Increment and Decrement topic in section Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Right option is (a) INCREMENT OPERATOR ++ ADDS 1 to its operand |
|
| 81. |
How many real types are there in complex numbers?(a) 1(b) 2(c) 3(d) 4I had been asked this question by my school principal while I was bunking the class.Asked question is from Complex Number Type in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The correct answer is (c) 3 |
|
| 82. |
Pick out the compound assignment statement.(a) a = a – 5(b) a = a / b(c) a -= 5(d) a = a + 5This question was posed to me in final exam.This question is from Essential Operators in section Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The correct answer is (c) a -= 5 |
|
| 83. |
Which is used to define the member of a class externally?(a) :(b) ::(c) #(d) !!$This question was addressed to me in final exam.My doubt stems from Classes in chapter Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The correct OPTION is (b) :: |
|
| 84. |
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 mentionedI had been asked this question in my homework.The question is from Large Objects topic in section Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» RIGHT answer is (d) All of the mentioned Explanation: Some of the ways to STOP the program by consuming more ram. They are i) Find a way to work with the DATA one at a time ii) Declare it in program MEMORY, instead of on the stack iii) Use the hard DRIVE, instead of RAM |
|
| 85. |
To use internal linkage we have to use which keyword?(a) static(b) extern(c) static or extern(d) publicI got this question during a job interview.Asked question is from Linkage in division Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The correct choice is (a) STATIC |
|
| 86. |
What is a friend function in C++?(a) A function which can access all the private, protected and public members of a class(b) A function which is not allowed to access any member of any class(c) A function which is allowed to access public and protected members of a class(d) A function which is allowed to access only public members of a classThis question was posed to me during an interview for a job.This interesting question is from Friend Function in section Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» The CORRECT answer is (a) A function which can access all the private, protected and public MEMBERS of a CLASS |
|
| 87. |
What does a class in C++ holds?(a) data(b) functions(c) both data & functions(d) arraysThis question was posed to me in quiz.My question comes from Classes topic in section Source Files, Classes and Operator Overloading in C++ of C++ |
|
Answer» Right answer is (C) both data & functions |
|