Home Interview Questions and AnswersPlacement Papers with Answers TCS Technical Interview Questions and Answers For Freshers Part-4

tcs img31.Advantages of a macro over a function?

Macro gets to see the Compilation environment, so it can expand #defines. It is expanded by the preprocessor.

32.What are the different storage classes in C?

Auto,register,static,extern

33.Which header file should you include if you are to develop a function which can accept variable number of arguments?

stdarg.h

34.What is cache memory ?

Cache Memory is used by the central processing unit of a computer to reduce the average time to access memory. The cache is a smaller, faster memory

which stores copies of the data from the most frequently used main memory locations. As long as most memory accesses are cached memory locations, the average
latency of memory accesses will be closer to the cache latency than to the latency of main memory.

35.What is debugger?
A debugger or debugging tool is a computer program that is used to test and debug other programs

36. Const char *p , char const *p What is the difference between the above two?   

1) const char *p – Pointer to a Constant char (‘p’ isn’t modifiable but the pointer is)
2) char const *p – Also pointer to a constant Char

However if you had something like:
char * const p – This declares ‘p’ to be a constant pointer to an char. (Char p is modifiable but the pointer isn’t)

37. What is Memory Alignment?  

Data structure alignment is the way data is arranged and accessed in computer memory. It consists of two separate but related issues: data alignment and data structure padding.

38.Explain the difference between ‘operator new’ and the ‘new’ operator?   

The difference between the two is that operator new just allocates raw memory, nothing else. The new operator starts by using operator new to allocate memory, but then it invokes the constructor for the right type of object, so the result is a real live object created in that memory. If that object contains any other objects (either embedded or as base classes) those constructors as invoked as well.

39. Difference between delete and delete[]?    

The keyword delete is used to destroy the single variable memory created dynamically which is pointed by single pointer variable.

Eg: int *r=new(int)
the memory pointed by r can be deleted by delete r.
delete [] is used to destroy array of memory pointed by single pointer variable.
Eg:int *r=new(int a[10])
The memory pointed by r can be deleted by delete []r.

40. What is conversion constructor?    

A conversion constructor is a single-parameter constructor that is declared without the function specifier ‘explicit’. The compiler uses conversion constructors to convert objects from the type of the first parameter to the type of the conversion constructor’s class.To define implicit conversions, C++ uses conversion constructors, constructors that accept a single parameter and initialize an object to be a copy of that parameter.

You may also like

Leave a Comment