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.
| 1. |
Where are standard exception classes grouped?(a) namespace std(b) error(c) catch(d) finalThe question was asked in my homework.Question is taken from Standard Exceptions topic in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right ANSWER is (a) namespace STD |
|
| 2. |
What will happen if an exception that is thrown may cause a whole load of objects to go out of scope?(a) Terminate the program(b) Produce a runtime error(c) It will be added to the overhead(d) Compilation errorI had been asked this question by my school principal while I was bunking the class.I would like to ask this question from Exceptions and Efficiency topic in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» RIGHT answer is (c) It will be added to the overhead For explanation: It will be added to the overhead if an EXCEPTION that is THROWN may cause a WHOLE load of OBJECTS to go out of scope. |
|
| 3. |
What will happen when we move to try block far away from catch block?(a) Reduces the amount of code in cache(b) Increases the amount of code in cache(c) Don’t alter anything(d) Increases the amount of codeThis question was posed to me by my school teacher while I was bunking the class.The above asked question is from Exceptions and Efficiency in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The correct answer is (a) Reduces the amount of code in cache |
|
| 4. |
How many parameters does the throw expression can have?(a) 1(b) 2(c) 3(d) 4The question was posed to me in semester exam.My question is based upon Catching Exceptions in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The CORRECT CHOICE is (a) 1 |
|
| 5. |
What is the syntax of inheritance of class?(a) class name(b) class name: access specifier(c) class name: access specifier class name(d) access specifier class nameI had been asked this question in a national level competition.The above asked question is from Design of Class Hierarchies in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct ANSWER is (C) class name: access specifier class name |
|
| 6. |
What operation can be performed by destructor?(a) Abort the program(b) Resource cleanup(c) Exit from the current block(d) Terminate the programI had been asked this question at a job interview.This question is from Exceptions and Efficiency topic in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The correct choice is (b) RESOURCE cleanup |
|
| 7. |
What do you mean by “No exception specification”?(a) It throws nothing(b) It can throw anything(c) It can catch anything(d) It can try anythingThe question was posed to me in a job interview.The origin of the question is Exception Specifications in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The CORRECT choice is (B) It can throw ANYTHING |
|
| 8. |
How many types of exception handling are there in c++?(a) 1(b) 2(c) 3(d) 4I got this question in my homework.The query is from Grouping of Exceptions in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» RIGHT choice is (b) 2 The best explanation: There are two TYPES of exception HANDLING in c++. They are SYNCHRONOUS exception handling and asynchronous exception handling. |
|
| 9. |
How many components STL has?(a) 1(b) 2(c) 3(d) 4I have been asked this question during a job interview.I want to ask this question from Standard Template Library in section Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The CORRECT choice is (d) 4 |
|
| 10. |
What can be passed by non-type template parameters during compile time?(a) int(b) float(c) constant expression(d) stringI have been asked this question in exam.Query is from Function Templates topic in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The CORRECT CHOICE is (c) CONSTANT EXPRESSION |
|
| 11. |
What may be the name of the parameter that the template should take?(a) same as template(b) same as class(c) same as function(d) same as memberThe question was posed to me during an interview for a job.This intriguing question originated from Simple String Template topic in section Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» RIGHT OPTION is (a) same as TEMPLATE For EXPLANATION: The name of the parameter that the template should TAKE same as the template. |
|
| 12. |
Pick out the correct option.(a) We cannot make an instance of an abstract base class(b) We can make an instance of an abstract base class(c) We can make an instance of an abstract super class(d) We can make an instance of an abstract derived classThis question was posed to me in a national level competition.Question is taken from Abstract Classes in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct ANSWER is (a) We cannot MAKE an instance of an ABSTRACT base class |
|
| 13. |
Which operator is used to declare the destructor?(a) #(b) ~(c) @(d) $This question was addressed to me in a national level competition.This key question is from Derived Classes in section Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The correct option is (b) ~ |
|
| 14. |
What are the disadvantages if use return keyword to return error codes?(a) You have to handle all exceptional cases explicitly(b) Your code size increases dramatically(c) The code becomes more difficult to read(d) All of the mentionedThe question was posed to me in unit test.Question is from Error Handling Alternatives topic in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right option is (d) All of the mentioned |
|
| 15. |
Which alternative can replace the throw statement?(a) for(b) break(c) return(d) exitThis question was addressed to me during an interview.Asked question is from Error Handling Alternatives in section Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right OPTION is (c) RETURN |
|
| 16. |
What is an exception in C++ program?(a) A problem that arises during the execution of a program(b) A problem that arises during compilation(c) Also known as the syntax error(d) Also known as semantic errorThe question was asked in an internship interview.My query is from Exception Handling topic in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The correct OPTION is (a) A PROBLEM that arises during the execution of a program |
|
| 17. |
Pick out the correct answer.(a) Exceptions are not suitable for critical points in code(b) Exception are suitable for critical points in code(c) Exceptions are used when postconditions of a function cannot be satisfied(d) Throw block should be placed after try blockI got this question in an online quiz.This key question is from Grouping of Exceptions in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» CORRECT answer is (a) Exceptions are not SUITABLE for critical points in code The explanation is: If there is many number of exceptions in the program means, We have to USE MULTIPLE catch STATEMENT and it is hard to keep track of the program. |
|
| 18. |
What are Container Adaptors?(a) Containers that implements data structures which can be accessed sequentially(b) Containers that implements sorted data structures for fast search in O(logn)(c) Containers that implements unsorted(hashed) data structures for quick search in O(1)(d) Containers that provide a different interface for sequential containersThe question was posed to me in an online interview.Origin of the question is Standard Template Library topic in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right CHOICE is (d) CONTAINERS that provide a different interface for sequential containers |
|
| 19. |
What is meant by container ship?(a) class contains objects of other class types as its members(b) class contains objects of other class types as its objects(c) class contains objects of other class types as its members 7 also objects(d) class contains objects of other class types as its members 9 also objectsI have been asked this question in class test.Enquiry is from Class Hierarchies and Abstract Classes topic in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The correct option is (a) class contains OBJECTS of other class TYPES as its members |
|
| 20. |
Pick out the correct statement about the override.(a) Overriding refers to a derived class function that has the same name and signature as a base class virtual function(b) Overriding has different names(c) Overriding refers to a derived class(d) Overriding has different names & it refers to a derived classThe question was asked in examination.The question is from Design of Class Hierarchies in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The CORRECT answer is (a) OVERRIDING REFERS to a derived class function that has the same name and SIGNATURE as a base class virtual function |
|
| 21. |
Which interface determines how your class will be used by another program?(a) public(b) private(c) protected(d) voidI got this question in exam.This interesting question is from Design of Class Hierarchies in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct choice is (a) public |
|
| 22. |
Which is the correct syntax of defining a pure virtual function?(a) pure virtual return_type func();(b) virtual return_type func() pure;(c) virtual return_type func() = 0;(d) virtual return_type func();I got this question at a job interview.The origin of the question is Abstract Classes in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» RIGHT answer is (C) VIRTUAL return_type func() = 0; Easiest explanation - virtual return_type function_name(PARAMETERS) = 0; where {=0} is called pure specifier. |
|
| 23. |
How to handle the exception in constructor?(a) We have to throw an exception(b) We have to return the exception(c) We have to throw an exception & return the exception(d) We have to catch an exceptionThe question was asked during an online exam.The question is from Catching Exceptions topic in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right option is (a) We have to THROW an EXCEPTION |
|
| 24. |
How many Associative Containers are provided by C++?(a) 2(b) 3(c) 4(d) 5This question was addressed to me in an international level competition.Question is taken from Standard Template Library in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct answer is (C) 4 |
|
| 25. |
Which is used to create a pure virtual function?(a) $(b) =0(c) &(d) !The question was asked during an internship interview.This question is from Abstract Classes topic in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct OPTION is (B) =0 |
|
| 26. |
How many types of standard exception are there in c++?(a) 9(b) 5(c) 6(d) 7The question was posed to me in an interview.This interesting question is from Standard Exceptions in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct OPTION is (a) 9 |
|
| 27. |
Pick out the correct statement for error handling alternatives.(a) Terminate the program(b) Use the stack(c) Exit from the block(d) Use the queueThis question was addressed to me in my homework.This interesting question is from Error Handling Alternatives topic in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The correct answer is (b) USE the stack |
|
| 28. |
What happens if try catch block is not used?(a) arise an error(b) program will run(c) execute continuously(d) wrong outputThe question was asked during an internship interview.The above asked question is from Uncaught Exceptions in section Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct OPTION is (a) arise an error |
|
| 29. |
How many types of Iterators are provided by C++?(a) 2(b) 3(c) 4(d) 5I got this question by my college director while I was bunking the class.My question is from Standard Template Library topic in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» RIGHT OPTION is (d) 5 Explanation: There are five TYPES of Iterators provided by C++ namely Input Iterators, OUTPUT Iterators, Forward Iterators, Bi-directional Iterators and Random-access Iterators. |
|
| 30. |
Which are done by compiler for templates?(a) type-safe(b) portability(c) code elimination(d) prototypeI got this question in semester exam.Query is from Simple String Template in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right answer is (a) type-safe |
|
| 31. |
How many kinds of classes are there in c++?(a) 1(b) 2(c) 3(d) 4I had been asked this question in homework.Query is from Class Hierarchies and Abstract Classes in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct CHOICE is (B) 2 |
|
| 32. |
What is an abstract class in C++?(a) Class specifically used as a base class with atleast one virtual functions(b) Class specifically used as a base class with atleast one pure virtual functions(c) Class from which any class is derived(d) Any Class in C++ is an abstract classThe question was asked in an interview for internship.I'm obligated to ask this question of Abstract Classes topic in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right answer is (B) Class specifically used as a base class with atleast one PURE VIRTUAL functions |
|
| 33. |
What will happen when a programs throws any other type of exception other than specified?(a) terminate(b) arise an error(c) run(d) throwThe question was posed to me during an internship interview.The doubt is from Exception Specifications topic in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right choice is (B) arise an error |
|
| 34. |
What kind of error can arise when there is a problem with memory?(a) Segmentation fault(b) Produce an error(c) Both Segmentation fault & Produce an error(d) runtime errorI got this question during an interview.My question is based upon Resource Management topic in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» RIGHT choice is (a) SEGMENTATION fault Explanation: segmentation fault error can ARISE when there is a problem with MEMORY. |
|
| 35. |
What are Unordered Associative Containers?(a) Containers that implements data structures which can be accessed sequentially(b) Containers that implements sorted data structures for fast search in O(logn)(c) Containers that implements unsorted(hashed) data structures for quick search in O(1)(d) Containers that implements data structures which can be accessed non-sequentiallyThe question was asked in unit test.My enquiry is from Standard Template Library topic in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» CORRECT answer is (C) Containers that implements UNSORTED(HASHED) data structures for quick search in O(1) To explain: Unordered Associative Containers is the SUBSET of Containers that implements unsorted(hashed) data structures for quick search in O(1) amortized O(n) Worst case complexity. |
|
| 36. |
What is a pure virtual function in C++?(a) A virtual function defined in a base class(b) A virtual function declared in a base class(c) Any function in a class(d) A function without definition in a base classThe question was asked during an interview.My enquiry is from Abstract Classes in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» RIGHT answer is (B) A virtual FUNCTION DECLARED in a base class The explanation is: Pure virtual function is a virtual function which has no definition/implementation in the base class. |
|
| 37. |
What is an error in C++?(a) Violation of syntactic and semantic rules of a languages(b) Missing of Semicolon(c) Missing of double quotes(d) Violation of program interfaceI got this question during an internship interview.Origin of the question is Exception Handling topic in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct option is (a) VIOLATION of syntactic and semantic RULES of a languages |
|
| 38. |
Which is used to handle the exceptions in c++?(a) catch handler(b) handler(c) exception handler(d) throwThe question was posed to me in an international level competition.My doubt stems from Exceptions That Are Not Errors in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The correct CHOICE is (c) exception handler |
|
| 39. |
What can go wrong in resource management on c++?(a) Leakage(b) Exhaustion(c) Dangling(d) ExceptionThe question was posed to me in my homework.Enquiry is from Resource Management topic in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right answer is (d) Exception |
|
| 40. |
How many Sequence Containers are provided by C++?(a) 2(b) 3(c) 4(d) 5I had been asked this question by my college director while I was bunking the class.Origin of the question is Standard Template Library in section Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct choice is (d) 5 |
|
| 41. |
What are the Sequence Containers?(a) Containers that implements data structures which can be accessed sequentially(b) Containers that implements sorted data structures for fast search in O(logn)(c) Containers that implements unsorted(hashed) data structures for quick search in O(1)(d) Containers that implements data structures which can be accessed non-sequentiallyI have been asked this question in an interview for job.I'm obligated to ask this question of Standard Template Library in section Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The correct OPTION is (a) Containers that IMPLEMENTS data STRUCTURES which can be accessed sequentially |
|
| 42. |
What is meant by pure virtual function?(a) Function which does not have definition of its own(b) Function which does have definition of its own(c) Function which does not have any return type(d) Function which does not have any return type & own definitionThe question was posed to me in an interview for job.My question is based upon Abstract Classes in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The CORRECT CHOICE is (a) Function which does not have DEFINITION of its own |
|
| 43. |
Which header file is used to declare the standard exception?(a) #include(b) #include(c) #include(d) #includeThis question was posed to me during an online exam.My question is based upon Standard Exceptions in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The CORRECT ANSWER is (a) #include |
|
| 44. |
Identify the correct statement about throw(type).(a) A function can throw any type of exceptions(b) A function can throw an exception of certain type only(c) A function can’t throw any type of exception(d) A function can catch all types of exceptionsThe question was asked during an interview.I want to ask this question from Exception Specifications topic in portion Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» RIGHT option is (B) A FUNCTION can throw an exception of CERTAIN type only Explanation: A function can throw an exception of certain type only. |
|
| 45. |
Which parameter is legal for non-type template?(a) pointer to member(b) object(c) class(d) baseclassThe question was posed to me in a job interview.My question is taken from Template Arguments to Specify Policy Usage topic in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» RIGHT ANSWER is (a) pointer to MEMBER Explanation: The following are legal for non-type template parameters:integral or enumeration type, Pointer to OBJECT or pointer to function, Reference to object or reference to function, Pointer to member. |
|
| 46. |
Pick out the correct statement about multiple inheritances.(a) Deriving a class from one direct base class(b) Deriving a class from more than one direct base class(c) Deriving a class from more than one direct derived class(d) Deriving a class from more than one direct derivedbase classThis question was posed to me by my college professor while I was bunking the class.My question comes from Design of Class Hierarchies topic in section Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The correct CHOICE is (B) Deriving a class from more than one direct base class |
|
| 47. |
Which is the correct statement about pure virtual functions?(a) They should be defined inside a base class(b) Pure keyword should be used to declare a pure virtual function(c) Pure virtual function is implemented in derived classes(d) Pure virtual function cannot implemented in derived classesThis question was addressed to me during an internship interview.This interesting question is from Abstract Classes in section Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» The CORRECT OPTION is (c) Pure virtual function is implemented in derived classes |
|
| 48. |
How many levels are there in exception safety?(a) 1(b) 2(c) 3(d) 4The question was asked during an online interview.I'd like to ask this question from Error Handling Alternatives in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct answer is (c) 3 |
|
| 49. |
What is the main purpose of the constructor?(a) Begin the execution of class(b) Include the macros for the program(c) Establish the class invariant(d) Terminate the programI have been asked this question in an interview.The question is from Exceptions and Efficiency topic in chapter Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Right ANSWER is (c) Establish the class invariant |
|
| 50. |
What is meant by garbage collection?(a) The form of manual memory management(b) The form of automatic memory management(c) Used to replace the variables(d) Used to delete the variablesI have been asked this question in an online quiz.I would like to ask this question from Resource Management topic in division Derived Classes, Templates & Exception Handling in C++ of C++ |
|
Answer» Correct choice is (b) The form of AUTOMATIC memory management |
|