C Interview Questions & Answers

Labels: , , , |

Q:What is Mutable?
Ans: this keyword can only be applied to non-static and non-const data members of a class. If a data member is declared mutable, then it is legal to assign a value to this data member from a const member function.
Mutable member-variable-declaration;

Q:What is c++ bit field?
Ans: Classes and structures can contain members that occupy less storage than an integral type. These members are specified as bit fields. The syntax for bit-field member-declarator specification follows:

Declarator: constant-expression

What is Memory Alignment?
Ans: Most CPUs require that objects and variables reside at particular offsets in the system's memory. For example, 32-bit processors require a 4-byte integer to reside at a memory address that is evenly divisible by 4. This requirement is called "memory alignment". Thus, a 4-byte int can be located at memory address 0x2000 or 0x2004, but not at 0x2001.

Q:What is dangling pointer?
Ans: Pointers that do not point to a valid object of the appropriate type. Dangling pointers arise when an object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory.

Q:What is in Name mangling?
Ans: Name mangling, (the more politically correct term is name-decoration, although it is rarely used) is a method used by a C++ compiler to generate unique names for identifiers in a program. The exact details of the algorithm are compiler-dependent, and they may vary from one version to another.

Q:What stack unwinding?
Ans: When an exception is thrown and control passes from a try block to a handler, the C++ run time calls destructors for all automatic objects constructed since the beginning of the try block. This process is called stack unwinding. The automatic objects are destroyed in reverse order of their construction.

1 comments:

Dev Ahir (SEOExpert) said...

hi Sandip,

Cool interview questions for C langauge.

thanks a lot for sharing the information.