C++ Interview Questions and Answers for Freshers

1. What is C++?
2. What is a modifier in C++?
3. What is an accessor in C++?
4. Differentiate between a template class and class template in C++?
5. When does a name clash occur in C++?
6. Define namespace in C++?
7. What is the use of 'using' declaration in C++?
8. What is an Iterator class in C++?
9. What is an incomplete type in C++?
10. What is a dangling pointer in C++?
11. Differentiate between the message and method in C++?
12. What is an adaptor class or Wrapper class in C++?
13. What is a Null object in C++?
14. What is class invariant in C++?
15. What do you mean by Stack unwinding in C++?
16. Define precondition and post-condition to a member function in C++?
17. What are the conditions that have to be met for a condition to be an invariant of the class?
18. What are proxy objects in C++?
19. Name some pure object oriented languages?
20. What is a node class in C++?
21. What is an orthogonal base class in C++?
22. What is a container class? What are the types of container classes in C++?
23. How do you write a function that can reverse a linked-list in C++?
24. What is polymorphism in C++?
25. How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
26. How can you tell what shell you are running on UNIX system?
27. What is Boyce Codd Normal form?
28. What is pure virtual function?
29. Write a Struct Time where integer m, h, s are its members
30. How do you traverse a Btree in Backward in-order?
31. What is the two main roles of Operating System?
32. In the derived class, which data member of the base class are visible?
33. How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
34. What is the difference between realloc() and free()?
35. What is function overloading and operator overloading?
36. What is the difference between declaration and definition?
37. What are the advantages of inheritance in C++?
38. How do you write a function that can reverse a linked-list?
39. What do you mean by inline function?
40. Write a program that ask for user input from 5 to 9 then calculate the average?
41. Write a short code using C++ to print out all odd number from 1 to 100
42. What is public, protected, private in C++?
43. Write a function that swaps the values of two integers, using int* as the argument type.
44. Tell how to check whether a linked list is circular.
45. What is virtual constructors/destructors?
46. What is the difference between an ARRAY and a LIST?
47. Does C++ support multilevel and multiple inheritance?
48. What is a template in C++?
49. Define a constructor - What it is and how it might be called (2 methods).
50. You have two pairs: new() and delete() and another pair : alloc() and free().
51. What is the difference between class and structure in C++?
52. What is RTTI in C++?
53.What is encapsulation in C++?
54. What is a C++ object?
55. Describe PRIVATE, PROTECTED and PUBLIC - the differences and give examples.
56. What is C++ namespace?
57. What do you mean by inheritance?
58. What is a COPY CONSTRUCTOR and when is it called?
59. What is Boyce Codd Normal form in C++?
60. What is virtual class and friend class?
61. What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?
62. What do you mean by binding of data and functions?
63. What are 2 ways of exporting a function from a DLL?
64. What is the difference between an object and a class?
65. Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].
66. What is a C++ class?
67. What is friend function in C++?
68. Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?
69. What is abstraction in C++?
70. What are virtual functions in C++?
71. What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator.
72. What is a scope resolution operator?
73. What do you mean by pure virtual functions?
74. What is polymorphism in C++? Explain with an example?
75. How can you quickly find the number of elements stored in a a) static array b) dynamic array ?
Why is it difficult to store linked list in an array?
76. What is the output of the following program? Why?
77. Why are arrays usually processed with for loop?
78. What is an HTML tag?
79.  Explain which of the following declarations will compile and what will be constant...
80. You are given a simple code for the class BankCustomer. Write the following functions ...
81. What problems might the following macro bring to the application?
82. Anything wrong with this code?
83. Anything wrong with this code?
84. How do you decide which integer type to use?
85. What is the best way to declare and define global variables?
86. What does extern mean in a function declaration?
87. What can I safely assume about the initial values of variables which are not explicitly initialized?
88. What is the difference between char a[] = "string"; and char *p = "string";?
89. What is the auto keyword good for in C++?
90. How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
91. What does extern mean in a function declaration in C++?
92. How do I initialize a pointer to a function?
93. How do you link a C++ program to C functions?
94. Explain the scope resolution operator.
95. What are the differences between a C++ struct and C++ class?
96. How many ways are there to initialize an int with a constant?
97. How does throwing and catching exceptions differ from using setjmp and longjmp?
98. What is a default constructor in C++?
99. What is a conversion constructor C++?
100. What is the difference between a copy constructor and an overloaded assignment operator?
101. When should you use multiple inheritance?
102. Explain the ISA and HASA class relationships. How would you implement each in a class design?
103. When is a template a better solution than a base class?
104. What is a mutable member?
105. What is an explicit constructor?
106. What is the Standard Template Library (STL)?
107. Describe run-time type identification.
108. What problem does the namespace feature solve?
109. Are there any new intrinsic (built-in) data types?
110. Will the following program execute?