Interview Question for CPP Language

1. What is C language?

C is a programming language developed at AT & T’s Bell Laboratories of USA in 1972.The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to many other operating systems, and is one of the most widely used programming languages.


2. What are the types of constants in c?

C constants can ba divided into two categories :

1. Primary constants
2. Secondary constants


 3. 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


4. What is a pointer?

Pointers are variables which stores the address of another variable. That variable may be a scalar (including another pointer), or an aggregate (array or structure). The pointed-to object may be part of a larger object, such as a field of a structure or an element in an array.


5. What is the difference between arrays and pointers?

Pointers

Pointers are used to manipulate data using the address. Pointers use • operator toaccess the data pointed to by them.

Arrays

Arrays is a collection of similar datatype. Array use sub-scripted variables to access and manipulate data. Array variables can be Equivalently written using pointer.


6. 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.


7. What are the uses of a pointer?

Pointer is used in the following casesIt is used to access array elements.

1. It is used for dynamic memory allocation.
2. It is used in Call by reference.
3. It is used in data structures like trees, graph, linked list etc.


8. What is the purpose of main() function?

The function main() invokes other functions within it.It is the first function to be called when the program starts execution.

1. It is the starting function.
2. It returns an int value to the environment that called the program.
3. Recursive call is allowed for main( ) also.
4. It is a user-defined function.


9. What are the different storage classes in C?

There are four types of storage classes.

1. Automatic 2. Extern 3. Regiter 4. Static


10. Define inheritance?

Inheritance is the process by which objects of one class acquire properties of objects of another class.


11. Define destuctors?

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


12. What is a structure?

Structure constitutes a super data type which represents several different data types in a single unit. A structure can be initialized if it is static or global.


13. 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.


14. Define Constructors?

A constructor is a member function with the same name as its class. The constructor is invoked whenever an object of its associated class is created.It is called constructor because it constructs the values of data members of the class.


15. What is dynamic binding?

Dynamic binding (also known as late binding) means that the code associated with a given procedure call is not known until the time of the call at run time.It is associated with polymorphism and inheritance.


16. what is an abstract base class?

An abstract class is a class that is designed to be specifically used as a base class. An abstract class contains at least one pure virtual function.


17. What is the difference between class and structure?

By default, the members or structures are public while that tor class is private. structures doesn’t provide something like data hiding which is provided by the classes. structures contains only data while class bind both data and member functions.


18. What is static identifier?

A file- scope variable that is declared static is visible only to functions within that file. A function -scope or block-scope variable that is declared as static is visible only within that scope.Further more, static variables only have a single instance. In the case of function- or block-scope variables, this means that the variable is not “automatic” and thus retains its value across function invocations.


19. What is a dynamic constructor?

The constructor can also be used to allocate memory while creating objects. Allocation of memory to objects at the time of their construction is known as dynamic construction of objects.The memory is allocated with the help of the new operator.


20. What is the difference between an Array and a List?

The main difference between an array and a list is how they internally store the data. whereas Array is collection of homogeneous elements. List is collection of heterogeneous elements.


21. What are the advantages of inheritance?

Main advantages of using Inheritance are:

1. Code reusability
2. Saves time in program development.


22. What is difference between function overloading and operator overloading?

A function is overloaded when same name is given to different function. While overloading a function, the return type of the functions need to be the same.


23. Define a class?

A class represents description of objects that share same attributes and actions. It defines the characteristics of the objects such as attributes and actions or behaviors. It is the blue print that describes objects.


24. What is the term Polymorphism?

To override a method, a subclass of the class that originally declared the method must declare a method with the same name, return type (or a subclass of that return type), and same parameter list.


25. What is Overriding?

The main difference between an array and a list is how they internally store the data. whereas Array is collection of homogeneous elements. List is collection of heterogeneous elements.


26. What is encapsulation?

Containing and hiding information about an object, such as internal data structures andcode. Encapsulation isolates the internal complexity of an object’s operation from the rest of the application.


27. What is a pointer variable?

A function is overloaded when same name is given to different function. While overloading a function, the return type of the functions need to be the same.


28. What is the difference between a string copy (strcpy) and a memory copy (memcpy)?

The strcpy() function is designed to work exclusively with strings. It copies each byte of the source string to the destination string and stops when the terminating null character () has been moved. On the other hand, the memcpy() function is designed to work with any type of data. Because not all data ends with a null character, you must provide the memcpy() function with the number of bytes you want to copy from the source to the destination.


29. What is the difference between a NULL Pointer and a NULL Macro?

Null pointer is a pointer that is pointing nothing while NULL macro will used for replacing 0 in program as #define NULL 0 .


Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *