91-9990449935 0120-4256464 |
C++ Interview QuestionsA list of top frequently asked C++ interview questions and answers are given below. 1) What is C++?C++ is an object oriented programming language created by Bjarne Stroustrup. It is released in 1985. 2) What are the advantages of C++?C++ doesn't only maintains all aspects from C language, it also simplify memory management and add several features like:
3) What is the difference between C and C++?
4) What is the difference between reference and pointer?
5) What is a class?Class is a user-defined data type. Class defines the type definition of category of things. It defines a datatype, but it does not define the data it just specifies the structure of data. You can create N number of objects from a class. 6) What is an object?Object is the instance of a class. A class provides a blueprint for objects. So you can create an object from a class. The objects of a class are declared with the same sort of declaration that we declare variables of basic types. 7) What are the C++ access specifiers?The access specifiers are used to define how to functions and variables can be accessed outside the class. There are three types of access specifiers:
8) What is Object Oriented Programming (OOP)?OOP is a methodology or paradigm that provides many concepts. The basic concepts of Object Oriented Programming are given below: Classes and Objects: Classes are used to specify the structure of the data. They define datatype. You can create any number of objects from a class. Objects are the instances of classes. Encapsulation: Encapsulation is a mechanism which binds the data and associated operations together and thus hide the data from outside world. Encapsulation is also known as data hiding. In C++, It is achieved using the access specifiers i.e. public, private and protected . Abstraction: Abstraction is used to hide the internal implementations and show only the necessary details to the outer world. Data abstraction is implemented using interfaces and abstract classes in C++. Some people confused about Encapsulation and abstraction. But they both are different. Inheritance: Inheritance is used to inherit the property of one class into another class. It facilitates you to define one class in term of another class. 9) What is the difference between array and a list?
10) What is the difference between new() and malloc()?
11) What are the methods of exporting a function from a DLL?There are two ways:
12) Define friend function.Friend function acts as friend of the class. It can access the private and protected members of the class. The friend function is not a member of the class but it must be listed in the class definition. 13) What is virtual function?A virtual function is used to replace the implementation provided by the base class. The replacement is always called whenever the object in question is actually of the derived class, even if the object is accessed by a base pointer rather than a derived pointer. 14) When should we use multiple inheritance?You can answer this question in three manners: 15) What is the destructor?Destructor is used to delete any extra resources allocated by the object. 16) What is an overflow error?It is a type of arithmetical error. It is happen when the result of an arithmetical operation been greater than the actual space provided by the system. 17) What is overloading?C++ facilitates you to specify more than one definition for a function name or an operator in the same scope. It is called function overloading and operator overloading respectively. 18) What is function overriding?If you inherit a class into a derived class and provide a definition for one of the base class's function again inside the derived class, then this function is called overridden function and this mechanism is known as function overriding. 19) What is virtual inheritance?Virtual inheritance facilitates you to create only one copy of each object even if the object appears more than one in the hierarchy. 20) What is constructor?Constructor is a special method that initializes object. It name must be same as class name. 21) What is the purpose of "delete" operator?The "delete" operator is used to release the dynamic memory created by "new" operator. 22) Explain this pointer?This pointer holds the address of current object. 23) What does Scope Resolution operator?A scope resolution operator(::) is used to define the member function outside the class. 24) What is the difference between delete and delete[]?Delete [] is used to release the array of allocated memory which was allocated using new[] whereas delete is used to release one chunk of memory which was allocated using new. 25) Define the private, protected and public in C++?Private: The data members and functions cannot be accessed from outside the class. Protected: The data members and functions are accessible to derived class only. Public: The data members and functions can be accessed from outside the class. |