CPP Interview Questions Download PDF

1 . What is C++ ?

C++ is a Object Oriented Programming Language supporting all the featues of OOPs.

2 . What are the differences between C and C++?

1) C++ is a kind of superset of C, most of C programs except few exceptions (See this and this) work in C++ as well. 2) C is a procedural programming language, but C++ supports both procedural and Object Oriented programming. 3) Since C++ supports object oriented programming, it supports features like function overloading, templates, inheritance, virtual functions, friend functions. These features are absent in C. 4) C++ supports exception handling at language level, in C exception handling is done in traditional if-else style. 5) C++ supports references, C doesn’t. 6) In C, scanf() and printf() are mainly used input/output. C++ mainly uses streams to perform input and output operations. cin is standard input stream and cout is standard output stream.

3 . What is Object Oriented Programming?

Object Oriented Programming (OOP) is a programming paradigm where the complete software operates as a bunch of objects talking to each other. An object is a collection of data and methods that operate on its data. Why OOP? The main advantage of OOP is better manageable code that covers following. 1) The overall understanding of the software is increased as the distance between the language spoken by developers and that spoken by users. 2) Object orientation eases maintenance by the use of encapsulation. One can easily change the underlying representation by keeping the methods same. OOP paradigm is mainly useful for relatively big software. See this for a complete example that shows advantages of OOP over procedural programing.

4 . What is a class?

Class is a blue print which reflects the entities attributes and actions. Technically defining a class is designing an user defined data type.

5 . What is an object?

An instance of the class is called as object.

6 . What is encapsulation?

The process of binding the data and the functions acting on the data together in an entity (class) called as encapsulation.

7 . What is inheritance?

Inheritance is the process of acquiring the properties of the exiting class into the new class. The existing class is called as base/parent class and the inherited class is called as derived/child class.

8 . What is the purpose of Inheritance?

The idea of inheritance is simple, a class is based on another class and uses data and implementation of the other class. The purpose of inheritance is Code Reuse.

9 . What is an inline function?

A function prefixed with the keyword inline before the function definition is called as inline function. The inline functions are faster in execution when compared to normal functions as the compiler treats inline functions as macros.

10 . Mention the storage classes names in C++.

The following are storage classes supported in C++ auto, static, extern, register and mutable

Post Question Details