C++ Interview Questions and Answers

C++ is one of the most popular language and C++ is the successor of C programming language. The interview question for C++ is explained in the form of questions and answers. These are the basic and most commonly asked interview question.

1. What is C++?

C++ is Object Oriented Programming Language and it is the successor of C programming language. C++ was developed during 1979 by Murray Hills at Bell Labs. C++ is the intermediate language and supports OOPs concepts like Encapsulation, Inheritance, etc.

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

  • C is low level language and C++ is middle level language
  • C does not supports OOP concepts like Abstraction, Encapsulation etc. whereas C++ supports it.
  • Execution in C language starts from top to bottom whereas in C++ execution is bottom to top.
  • C does not support exception handling while C++ has built-in support for exception handling

3. What are the advantage of C++ over C programming Language?

The major C++ language over C language is that C++ support OOP concept. C++ has Inheritance, Encapsulation, Abstraction etc. C++ has built-in support for exceptional handling and operator overloading is possible in C++.

4. What is OOP?

OOP stands for Object Oriented Programming. It is the programming model for high and middle level languages like Java, C++ etc. implemented for better reusability, security with OOP concept like Encapsulation, Inheritance, Abstractions etc.

5. Write Hello World Program using C++?

The Hello World program for C++ is given below:

6. What are C++ keywords?

C++ keywords are the reserved words. Keywords cannot be used has variable, constant and functions. Some of the C++ keywords are int, sizeof, continue, enum etc.

7. Explain identifiers in C++?

In C++, identifiers are used naming variable, function etc. The variable or function name may start with a – z or with _ like hello, _count, _12hh, good etc.

8. Define Whitespace in C++?

Whitespace are space, new line etc. which are ignore by the C++ during compilation and execution.

Example 1: With Blank Space, new line etc.

Example 2: Without new line and blank space.

Example 1 and Example 2 will produce the same output.

9. Write a C++ program to demonstrate operators?

Assignment operator, arithmetic operator, increment and decrement are some the C++ operators.

Example for demonstrating Assignment and Arithmetic Operator:

10. What is the difference between break and continue?

The break statement will terminate the loops and further execution of program will be stopped whereas the continue statement won’t stop flow of program.

Next Page>>