Interview Questions C

C


181. What are static functions? What is their use?
In C, functions are global by default. The "static" keyword before a function name makes it static. Unlike global functions in C, access to static functions is restricted to the file where they are declared. Therefore, when we want to restrict access to functions, we make them static. Another reason for making functions static can be reuse of the same function name in other files. See thisfor examples and more details. 

182. What are the types of constants in c?
C constants can ba divided into two categories :
1. Primary constants
2. Secondary constants

183. What are the types of C intructions?
Now that we have written a few programs let us look at the instructions that we used in these programs. There are basically three types of instructions in C :
1. Type Declaration Instruction
2. Arithmetic Instruction
3. Control Instruction

184. What is the difference between arrays and pointers?
Pointers are used to manipulate data using the address. Pointers use ? operator to access the data pointed to by them.
Arrays is a collection of similar datatype. Array use subscripted variables to access and manipulate data. Array variables can be Equivalently written using pointer expression.

185. What is "this"s pointer?
The this pointer is a pointer accessible only within the member functions of a class, struct, or union type. It points to the object for which the member function is called. Static member functions do not have a this pointer.

186. Define inheritance?
Inheritance is the process by which objects of one class acquire properties of objects of another class.

187. Define destuctors?
: A destructor is called for a class object when that object passes out of scope or is explicitly deleted. 
1. A destructors as the name implies is used to destroy the objects that have been created by a constructors.
2. Like a constructor , the destructor is a member function whose name is the same as the class name but is precided by a tilde.

188. What is message passing?
An object oriented program consists of a set of objects that communicate with each other. Message passing involves specifying the name of the object, the name of the function and the information to be sent.

189. Define Constructors?
1. Ans: A constructor is a member function with the same name as its class. 
2. The constructor is invoked whenever an object of its associated class is created.
3. It is called constructor because it constructs the values of data members of the class.

190. What is the use of default constructor?
A constructors that accepts no parameters is called the default constructor.If no user-defined constructor exists for a class A and one is needed, the compiler implicitly declares a default parameterless constructor A::A(). This constructor is an inline public member of its class. The compiler will implicitly define A::A() when the compiler uses this constructor to create an object of type A. The constructor will have no constructor initializer and a null body.