C++ Programming – Interview Questions

Practice interview questions by difficulty level

Showing: All Questions
Q1. What is C++?
Beginner Level
C++ is a general-purpose, object-oriented programming language.
Q2. Who developed C++?
Beginner Level
C++ was developed by Bjarne Stroustrup.
Q3. What is the extension of C++ file?
Beginner Level
.cpp is the standard extension of C++ files.
Q4. What is main() function?
Beginner Level
main() is the entry point of a C++ program.
Q5. What is a variable?
Beginner Level
A variable stores data values.
Q6. What are data types in C++?
Beginner Level
int, float, double, char, bool etc.
Q7. What is cout?
Beginner Level
cout is used to print output in C++.
Q8. What is cin?
Beginner Level
cin is used to take input from the user.
Q9. What is namespace std?
Beginner Level
It avoids name conflicts in C++.
Q10. What is header file?
Beginner Level
Header file contains declarations of functions.
Q11. What is comment?
Beginner Level
Comments are ignored by compiler and used for explanation.
Q12. What is operator?
Beginner Level
Operator performs operations on variables.
Q13. What is loop?
Beginner Level
Loop repeats execution of code.
Q14. What are loop types?
Beginner Level
for, while, and do-while.
Q15. What is array?
Beginner Level
Array stores multiple values of same data type.
Q16. What is string?
Beginner Level
String is a sequence of characters.
Q17. What is function?
Beginner Level
Function is a block of reusable code.
Q18. What is return statement?
Beginner Level
return sends value back to caller.
Q19. What is class?
Beginner Level
Class is a blueprint for objects.
Q20. What is object?
Beginner Level
Object is an instance of a class.
Q21. What is constructor?
Beginner Level
Constructor initializes an object.
Q22. What is destructor?
Beginner Level
Destructor releases resources of object.
Q23. What is OOP?
Beginner Level
OOP is programming based on objects and classes.
Q24. What is encapsulation?
Beginner Level
Binding data and methods together.
Q25. What is inheritance?
Beginner Level
One class acquires properties of another.
Q26. What is polymorphism?
Beginner Level
Ability to take multiple forms.
Q27. What is abstraction?
Beginner Level
Hiding implementation details.
Q28. What is access specifier?
Beginner Level
Defines accessibility of class members.
Q29. What are access specifiers?
Beginner Level
public, private, protected.
Q30. What is public keyword?
Beginner Level
Accessible from anywhere.
Q31. What is private keyword?
Beginner Level
Accessible only within class.
Q32. What is protected keyword?
Beginner Level
Accessible in class and derived classes.
Q33. What is struct?
Beginner Level
struct groups variables of different types.
Q34. Difference between struct and class?
Beginner Level
Default access is public in struct, private in class.
Q35. What is inline function?
Beginner Level
Function expanded at compile time.
Q36. What is reference variable?
Beginner Level
Alias name for another variable.
Q37. What is pointer?
Beginner Level
Pointer stores memory address.
Q38. What is bool data type?
Beginner Level
Stores true or false.
Q39. What is constructor overloading?
Intermediate Level
Multiple constructors with different parameters.
Q40. What is function overloading?
Intermediate Level
Same function name with different parameters.
Q41. What is operator overloading?
Intermediate Level
Redefining operators for user-defined types.
Q42. What is virtual function?
Intermediate Level
Function resolved at runtime.
Q43. What is runtime polymorphism?
Intermediate Level
Method call resolved during execution.
Q44. What is compile-time polymorphism?
Intermediate Level
Method resolution at compile time.
Q45. What is virtual destructor?
Intermediate Level
Ensures proper cleanup in inheritance.
Q46. What is base class?
Intermediate Level
Class from which other classes inherit.
Q47. What is derived class?
Intermediate Level
Class that inherits another class.
Q48. What is multiple inheritance?
Intermediate Level
Class inherits from multiple classes.
Q49. What is diamond problem?
Intermediate Level
Ambiguity in multiple inheritance.
Q50. What is virtual inheritance?
Intermediate Level
Prevents duplication of base class.
Q51. What is STL?
Intermediate Level
Standard Template Library.
Q52. What is vector?
Intermediate Level
Dynamic array from STL.
Q53. What is list?
Intermediate Level
Doubly linked list container.
Q54. What is map?
Intermediate Level
Stores key-value pairs in sorted order.
Q55. What is set?
Intermediate Level
Stores unique elements.
Q56. Difference between map and unordered_map?
Intermediate Level
map is ordered; unordered_map is hash-based.
Q57. What is iterator?
Intermediate Level
Used to traverse containers.
Q58. What is auto keyword?
Intermediate Level
Automatically deduces data type.
Q59. What is const keyword?
Intermediate Level
Prevents modification of value.
Q60. What is static keyword?
Intermediate Level
Shared among all objects of class.
Q61. What is dynamic memory allocation?
Intermediate Level
Allocating memory at runtime using new.
Q62. Difference between new and malloc?
Intermediate Level
new calls constructor; malloc does not.
Q63. What is delete operator?
Intermediate Level
Frees dynamically allocated memory.
Q64. What is shallow copy?
Intermediate Level
Copies object references.
Q65. What is deep copy?
Intermediate Level
Copies actual object data.
Q66. What is copy constructor?
Intermediate Level
Initializes object using another object.
Q67. What is assignment operator?
Intermediate Level
Assigns one object to another.
Q68. What is friend function?
Intermediate Level
Function that can access private members.
Q69. What is exception handling?
Intermediate Level
Handling runtime errors using try-catch.
Q70. What is namespace?
Intermediate Level
Prevents name conflicts.
Q71. What is file handling?
Intermediate Level
Reading and writing files.
Q72. What is fstream?
Intermediate Level
File stream class.
Q73. What is type casting?
Intermediate Level
Converting one data type to another.
Q74. What is explicit keyword?
Intermediate Level
Prevents implicit conversions.
Q75. What is mutable keyword?
Intermediate Level
Allows modification in const object.
Q76. What is lambda expression?
Intermediate Level
Anonymous function in C++.
Q77. What is RAII?
Advanced Level
Resource Acquisition Is Initialization technique.
Q78. What is smart pointer?
Advanced Level
Automatically manages memory.
Q79. Types of smart pointers?
Advanced Level
unique_ptr, shared_ptr, weak_ptr.
Q80. What is unique_ptr?
Advanced Level
Exclusive ownership smart pointer.
Q81. What is shared_ptr?
Advanced Level
Shared ownership smart pointer.
Q82. What is weak_ptr?
Advanced Level
Non-owning reference to shared_ptr.
Q83. What is move semantics?
Advanced Level
Transfers resources instead of copying.
Q84. What is rvalue reference?
Advanced Level
Reference to temporary objects.
Q85. What is std::move?
Advanced Level
Casts object to rvalue.
Q86. What is rule of five?
Advanced Level
Destructor, copy/move ctor and assign.
Q87. What is rule of zero?
Advanced Level
No custom memory management needed.
Q88. What is constexpr?
Advanced Level
Compile-time evaluation.
Q89. What is template?
Advanced Level
Generic programming mechanism.
Q90. What is template specialization?
Advanced Level
Custom implementation for specific type.
Q91. What is SFINAE?
Advanced Level
Substitution Failure Is Not An Error.
Q92. What is type traits?
Advanced Level
Compile-time type information.
Q93. What is std::variant?
Advanced Level
Type-safe union.
Q94. What is std::optional?
Advanced Level
Represents optional value.
Q95. What is multithreading?
Advanced Level
Concurrent execution using threads.
Q96. What is std::thread?
Advanced Level
Thread support library.
Q97. What is mutex?
Advanced Level
Prevents data races.
Q98. What is deadlock?
Advanced Level
Threads waiting indefinitely.
Q99. What is atomic operation?
Advanced Level
Operation executed without interruption.
Q100. What is memory leak?
Advanced Level
Unused memory not freed.
Q101. What is undefined behavior?
Advanced Level
Behavior not defined by standard.
Q102. What is ABI?
Advanced Level
Application Binary Interface.
Q103. What is linker?
Advanced Level
Combines object files.
Q104. What is compile-time optimization?
Advanced Level
Optimization during compilation.
Q105. What is runtime optimization?
Advanced Level
Optimization during execution.
Q106. What is cache coherence?
Advanced Level
Consistency of cached data.
Q107. What is false sharing?
Advanced Level
Performance issue due to cache lines.
Q108. What is polymorphic deletion?
Advanced Level
Deleting derived object via base pointer.
Q109. What is noexcept?
Advanced Level
Specifies function does not throw exceptions.
Q110. What is ODR?
Advanced Level
One Definition Rule.
Q111. What is PIMPL idiom?
Advanced Level
Pointer to implementation technique.
Q112. What is constexpr if?
Advanced Level
Compile-time conditional branching.