Interview Questions for C++

Description

The C++ language is an object-oriented programming language & is a combination of both low-level & high-level language – a Middle-Level Language. The programming language was created, designed & developed by a Danish Computer Scientist – Bjarne Stroustrup at Bell Telephone Laboratories (now known as Nokia Bell Labs) in Murray Hill, New Jersey. As he wanted a flexible & a dynamic language which was similar to C with all its features, but with additionally of active type checking, basic inheritance, default functioning argument, classes, inlining, etc. and hence C with Classes (C++) was launched.

This image has an empty alt attribute; its file name is 16-1024x373.jpg

  1. What is the full form of OOPS?

Object Oriented Programming System.

  1. What is the difference between reference and pointer?

Following are the differences between reference and pointer:

Reference

Pointer

Reference behaves like an alias for an existing variable, i.e., it is a temporary variable.

The pointer is a variable which stores the address of a variable.

Reference variable does not require any indirection operator to access the value. A reference variable can be used directly to access the value.

Pointer variable requires an indirection operator to access the value of a variable.

Once the reference variable is assigned, then it cannot be reassigned with different address values.

The pointer variable is an independent variable means that it can be reassigned to point to different objects.

A null value cannot be assigned to the reference variable.

A null value can be assigned to the reference variable.

It is necessary to initialize the variable at the time of declaration.

It is not necessary to initialize the variable at the time of declaration.

  1. What is a class?

The class is a user-defined data type. The class is declared with the keyword class. The class contains the data members, and member functions whose access is defined by the three modifiers are private, public and protected. The class defines the type definition of the category of things. It defines a data type, but it does not define the data it just specifies the structure of data. You can create N number of objects from a class.

  1. What is an object?

An instance of the class is called as object.

  1. If You Want To Share Several Functions Or Variables In Several Files Maintaining The Consistency How Would You Share It?

To maintain the consistency between several files firstly place each definition in ‘.c’ file than using external declarations put it in ‘.h’ file after it is included .h file we can use it in several files using #include as it will be in one of the header files, thus to maintain the consistency we can make our own header file and include it whereever needed.

  1. List the types of inheritance supported in C++?

Single

Multilevel

Multiple

Hierarchical

Hybrid.

6.     Define ‘std’.

Std is the default namespace standard used in C++.

7.     What are the advantages of C++?

C++ doesn’t only maintains all aspects from C language, it also simplifies memory management and adds several features like:

C++ is a highly portable language means that the software developed using C++ language can run on any platform.

C++ is an object-oriented programming language which includes the concepts such as classes, objects, inheritance, polymorphism, abstraction.

C++ has the concept of inheritance. Through inheritance, one can eliminate the redundant code and can reuse the existing classes.

Data hiding helps the programmer to build secure programs so that the program cannot be attacked by the invaders.

  • Message passing is a technique used for communication between the objects.
  • C++ contains a rich function library.

    8.  Who was the creator of C++?
Bjarne Stroustrup.

Bjarne Stroustrup.

  1. What is encapsulation?

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

10.    What is the full form of STL in C++?

STL stands for Standard Template Library.

  1. What is abstraction?

Abstraction refers to hiding the internal implementation and exhibiting only the necessary details.

  1. . What are the C++ accesses specifies?

The access specifies are used to define how to functions and variables can be accessed outside the class.

There are three types of access specifies:

  • Private: Functions and variables declared as private can be accessed only within the same class, and they cannot be accessed outside the class they are declared.
  • Public: Functions and variables declared under public can be accessed from anywhere.
  • Protected: Functions and variables declared as protected cannot be accessed outside the class except a child class. This specifies is generally used in inheritance.
  1. . When should we use multiple inheritances?

You can answer this question in three manners:

  1. Never
  2. Rarely
  3. If you find that the problem domain cannot be accurately modeled any other way.

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

   15.What is the difference between an array and a list?

An Array is a collection of homogeneous elements while a list is a collection of heterogeneous elements.

Array memory allocation is static and continuous while List memory allocation is dynamic and random.

In Array, users don’t need to keep in track of next memory allocation while In the list, the user has to keep in track of next location where memory is allocated.

 

comment 18


  1. AffiliateLabz

    Great content! Super high-quality! Keep it up! 🙂

    Reply

leave your comment


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