C++ Programming Interview Questions

Ques 1. What is C++ ?

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

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

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

Ques 3. What is Object Oriented Programming?

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

Ques 4. What is a class?

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

Ques 5. What is an object?

Ans. An instance of the class is called as object.

Ques 6. What is encapsulation?

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

Ques 7. What is inheritance?

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

Ques 8. What is the purpose of Inheritance?

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

Ques 9. What is an inline function?

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

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

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

Post Question Details

Ques. khhhhhhhhhhhhhkl

Posted On:3/4/2020 11:41:52 PM

Ques. ghh

Posted On:3/4/2020 11:19:57 PM