Explore
ProGrad Programs
Placement Prep
TCS Codevita
Live Placement Training
Webinars
About Us

Edit
Reply




Edit

Commonly Asked Technical Interview Questions on C++ Programming

Published on 06 Mar 2020

C++ is quite often the first Object Oriented Programming languages learnt by developers. Being one of the earliest object-oriented programming languages, it has gone on to influence many other programming languages. This also helps with the fact that if you learn C++, then learning any other object-oriented programming language becomes easy. In particular, C++ is one of the widely used programming languages in development, even after being 3 decades in existence. As a fresher in the software industry, it is important to be familiar with the basics of C++, particularly from the context of the technical interview. This page contains commonly asked technical interview questions for C++ Programming.


#1 How is C++ different from C?


C++ supports both procedural as well as object-oriented programming code (also known as a multi-paradigm), whereas C is purely a procedural language. C++ is particularly oriented towards protecting data. This is done using modifiers for class members. Data in C as we know is subject to security infiltrations. In C++, more than one variable can point to the same memory location through the support for reference variables. C does not support this. C++ has built-in exception handling capabilities, whereas C does not. C++ supports function overloading where a function can have more than one definition. C does not support this option.


#2 What is the difference between a class and an object?


A class can be thought of as a blueprint of a car. The blueprint itself does not create the car. It only specifies the structure of the car, what goes where, etc. By using this blueprint, you can specify dimensions for each element, which then can help in creating a car. The car can be likened to the object. Any number of cars can be created from a blueprint. Similarly, any number of objects can be created from a class. Class is hence the definition of a datatype, where the structure of the data is specified.


#3 What is encapsulation?


Encapsulation is a mechanism used by classes to hide data from outside of the class. Both the data and functions that work with the data are encapsulated within a class. Encapsulation is also called data hiding, due to its obvious function of hiding data. Every data type within a class will have access specifiers which basically details how data can be accessed. There are 3 access specifiers – private, public and protected.


#4 What is data abstraction?


Again using the car analogy, we know that stepping on the accelerator is going to accelerate the vehicle, and releasing the accelerator will slow the vehicle down. You need not bother about the inner complexities that are involved with the accelerator. It doesn’t matter if more petrol is entering the engine or if someone behind the car gets an instruction to push harder. This is similar to the concept of data abstraction. Within a class, there could be certain data and functions that it performs. However, all we need to know (as being a part of the outside world) is what a particular class does, not how it does it.


#5 What is Inheritance?


Inheritance is the mechanism through which one class inherits the properties of another. This helps in breaking programming code into modules and reusing code which in turn helps in optimizing for memory.


Help other candidates who are preparing for technical interviews for C++ by posting questions that you were asked in your interview in the comments. Also, if there are any technical interview C++ Programming questions that you had received, let us know and we will add it to the page along with the answers.


If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in
Explore 'c plus plus'
Articles Practice Exercises