1. What is C++?
A high-level programming language that supports object-oriented, procedural, and generic programming.
2. What are the main features of C++?
Object-oriented programming, inheritance, polymorphism, encapsulation, templates, and operator overloading.
3. What is the difference between C and C++?
C is a procedural language; C++ supports both procedural and object-oriented programming.
4. What are the types of comments in C++?
Single-line (//) and multi-line (/* ... */) comments.
5. What is a header file?
A file containing C++ declarations and macro definitions, typically included at the beginning of a program.
6. What is a class?
A blueprint for creating objects that encapsulate data and methods.
7. What is an object?
An instance of a class containing both data and methods.
8. What is inheritance?
A mechanism where one class derives properties and behavior from another class.
9. What is polymorphism?
The ability to present the same interface for different underlying forms (data types).
10. What is encapsulation?
The bundling of data and methods that operate on the data within a single unit (class).
11. What are built-in data types in C++?
int, char, float, double, and bool.
12. What is a reference variable?
An alias for another variable, allowing indirect access to its value.
13. What is the difference between struct and class?
Members of struct are public by default; members of class are private by default.
14. What is a pointer?
A variable that stores the memory address of another variable.
15. What is dynamic memory allocation?
The process of allocating memory at runtime using operators like new and delete.
16. What is the difference between for, while, and do-while loops?
for loops are used for a known number of iterations; while checks the condition before execution; do-while executes at least once.
17. What is a switch statement?
A control statement that executes a block of code based on the value of an expression.
18. What is a function in C++?
A block of code that performs a specific task and can return a value.
19. What is function overloading?
Defining multiple functions with the same name but different parameters.
20. What is function overriding?
Redefining a function in a derived class that already exists in the base class.
21. What is the inline keyword?
A suggestion to the compiler to insert the function's body directly into the calling code to reduce function call overhead.
22. What is recursion?
A technique where a function calls itself to solve a problem.
23. What is an exception?
An event that disrupts the normal flow of a program, typically due to errors.
24. What is the purpose of try and catch?
To handle exceptions gracefully without crashing the program.
25. What is the throw keyword?
Used to signal the occurrence of an exception.
26. What is a destructor?
A special member function that is called when an object goes out of scope or is deleted.
27. What is a try-catch-finally block?
A structure used to handle exceptions, with optional cleanup code in the finally block.
28. What are templates in C++?
A feature that allows writing generic functions and classes that work with any data type.
29. What is the Standard Template Library (STL)?
A powerful library that provides a set of common classes and functions for data structures and algorithms.
30. What is a vector?
A dynamic array provided by STL that can resize itself automatically.
31. What is a list?
A doubly-linked list provided by STL that allows non-contiguous memory allocation.
32. What is a map?
An associative container that stores key-value pairs with unique keys.
33. What is operator overloading?
The ability to redefine the meaning of operators for user-defined types.
34. What are friend functions?
Functions declared with the friend keyword that can access private and protected members of a class.
35. What is a copy constructor?
A constructor that initializes an object using another object of the same class.
36. What is a memory leak?
A situation where memory is allocated but not properly deallocated, leading to increased memory usage.
37. What is the stack and heap?
Stack is used for static memory allocation; heap is used for dynamic memory allocation.
38. What is the new operator?
Used to allocate memory for an object or array dynamically.
39. What is the delete operator?
Used to deallocate memory allocated with new.
40. What is file handling in C++?
The process of reading from and writing to files using streams.
41. What is binary file handling?
Reading from and writing to files in binary format, which allows for non-text data storage.
42. What is multithreading?
The ability to execute multiple threads concurrently within a single process.
43. What is a thread?
A lightweight process that can run independently.
44. What is a virtual function?
A function declared in a base class that can be overridden in derived classes to achieve polymorphism.
45. What is a pure virtual function?
A virtual function with no implementation in the base class, making the class abstract.
46. What is multiple inheritance?
A feature that allows a class to inherit from more than one base class.
47. What are namespaces?
A way to organize code and prevent name conflicts by grouping related identifiers.
48. What are inline functions?
Functions defined with the inline keyword to reduce function call overhead.
49. What is template specialization?
The ability to define different implementations of a template for specific data types.
50. What is the sizeof operator?
An operator that returns the size (in bytes) of a data type or object.
51. What are enumerations?
A user-defined data type that consists of integral constants, improving code readability.
52. What is the significance of main() function?
The entry point for any C++ program.
53. What are static members?
Members that belong to the class rather than any instance, shared across all instances.
54. What is nullptr?
A keyword representing a null pointer in C++11 and beyond.
© TeachMind G, All Right Reserved || Designed and Maintained by BTPL.