Saturday, December 4, 2021
HomeLatest Jobs50+ most asked c++ Programming Question

50+ most asked c++ Programming Question

Dear User,if you are preparing for interviews looking for most asked c++ interview question,so you landed on right platform.
here we will provide you top 50+ question which help you to crack any interviews easily.


1) What is C++ language?

Answer:

C++ is an object oriented programming language which is superset of c .

it support all feature of OOPS like Inheritance,Abstraction,polymorphism etc.

2) Who is the founder of C++ language?

Answer:

Bjarne Stroustrup

3) when it was developed?

Answer:

1985

4) what are the key feature of C++ programming?

Answer:

feature of C++ progamming:

1-it is object oriented programming language that mean it support feature like abstraction,encapsulation,polymorphism etc.

2-it support data hiding ,so that program will become secure.

3-it support the feature of reusability.

4-it is platform independent that mean program can run only platform .

5) what are the advantages of c++?

Answer:

it has various advantages:

1-it has standard template library ,which provide lots of premium data structure like vector,map.

2-it is easier to manage with the help of classes and object.

3-it supports OOPS concept,which provide feature like Inheritance,Polymorphism,Abstraction,Encapsulation.

6) What is the difference between C and C++?

Answer:

CC++
1-it is procedural language.1-it is object oriented language.
2-it was developed by dennis ritchie.2-it was developed by bjarne stroustrop.
3-it does not support data hiding.3-it support data hiding
4-scanf and printf is used for input and output.4-cin and cout is used for input and output.

7) define class?

Answer:

class is a user defined data type which is blueprint of object.

it is declared with class keyword.

8) define object?

Answer:

Object is an abstract data type which is instance of class.

.9) What are C++ access specifiers ?

Answer:

access specifiers is used to define accessibility of class.by default variable and function are declared private.

there are three access specifier:

1-public: member which declare public are accessible outside the class.

2-private:member which declared private are only accessible within class.

3-protected:member which declare protected are acccessible in derived class.

10)what is OOPS?

Answer:

OOPS stand for Object oriented programming which provide the feature of abstraction,encapsulation,polymorphism,inheritance.

11)explain encapsulation.with real life example?

Answer:

Encapsulation is a process in which data and their function are bind together to form a single unit.

for example:

A mobile number stores the contact detail in digital format and convert it into human readable form.and we dont know how mobile number is stored .and how it is converted in human readable form.


12)explain polymorphism.with real life example?

Answer:

polymorphism is a process which has the ability to keep same thing in multiple form.

For example:

A person is a son of his father ,husband of his wives and at the same time he is employee of company.that mean a person can exist in many form in a same time.


13)explain inheritance.with real life example?

Answer:

Inheritance is a process in which a class derived the properties from another class or parent class.

For example:

like in our family ,our parent are super class and we are the child class because we are inheriting properties from our parent.


14 explain abstraction.with real life example?

Answer:

Abstraction is a process in which we hide the implementation detail of the code and we are showing only the important detail to the end user.

for example:

if we take a example of motor bike,we know when we increase the accelerator then speed automatically increase but we dont know how it is happening .this is when abstraction come in play it hide the background detail and show only important info.


15)difference between malloc and new?

Answer:

mallocnew
1-malloc is an function1-new is an operator
2-return void 2-return datatype


16)difference between delete and free?

Answer:

deletefree
1-delete is an operator.1-free is an function
2-delete call destructor 2-free does not calll destructor.


17)what is inline function?

Answer:

The inline function in c++ is used to increase the execution time of program.

18)what is virtual function?

Answer:

Virtual function is a function which is declared in base class and overriden by the derived class.


19)what is constructor?

Answer:

constructor is a member function which initialize when object is created.


20)what is copy constructor?

Answer:

copy constructor is a constructor which initialise the object by another object of the same class.


21)what is default constructor?

Answer:

default constructor is a constructor which has no arguments.


22)what is parametrized constructor?

Answer:

parametrized constructor is a constructor which has argument .


23)what is friend function?

Answer:

when any function is declared as friend,it can access private and protected member of the class.

A function start with friend keyword is known as friend function.


24)what is friend class?

Answer:

friend class is a class which start with the friend keywords . it can acess private and protected member of the class.


25)what are the type of polymorphism?

Answer:

there are two type of polymorphism.

1-static polymorphism .

2-run time polymorphism.


26)what are runtime polymorphism?

Answer:

Runtime polymorphism are the polymorphism which resolved at runtime.

overriding is an example of static polymorphism.


27)what are static polymorphism?

Answer:

static polymorphism are the polymorphism which resolved at compile time.

overloading is an example of static polymorphism.


28)what is function overloading?

Answer:

when function with same name but with different argument are there then it is called function overloading.


29)what is operator overloading?

Answer:

operator overloading allow to define new data type from the builtin data type.


30)difference between overloading and overriding?

Answer:

In overloading, we define two or more method in the same class by same name but diffrent argument is called overloading.

In overriding,if the method name and parameter are same in super class and the child class is called overriding.

31)can we make copy constructor private?

Answer:

yes,we can make copy constructor.


33)define namespace in c++?

Answer:

namespace is a region which provide scope to identifier.


34)what is full form of stl?

Answer:

STL stands for standard template library.


35)when should we use multiple inheritance?

Answer:

when we have to inherit the property from more than one class theen we use multiple inheritance.


36)what is destructor?

Answer:

destructor is a function which automatically invokes to destroy object.


37)explain this pointer?

Answer:

this pointer refer to the own address of the object of class.


38)what is scope of variable?

Answer:

A scope of variable refer to the visibility of program .there are basically two type of scope of variables ,one is global scope variable which is accessed throughout the program. and another is local scope variabe which is accessed inside a particular block or function.


39)What is the difference between delete and delete[]?

Answer:

delete operator is used to delete non array object where delete[] operator is used to delete array object.


40)What is a pure virtual function?

Answer:

A pure virtual function is a function which is declared 0.


41)what is volatile keyword?

Answer:

volatile keyword applies on variable,which tells the compiler that value may change at any time.


42))difference between structure and class in c++?

Answer:

structureclass
1-struct keyword used1-class keyword used.
2-it is a data type which store the various data type.2-it is blueprint of object
3-by default member are public.3-by default member are private.


43)what is pointer

Answer:

Pointer is a variable which store the address of another variable.The variable that store the address value is known as pointer.


44)what is dangling pointer?

Answer:

A pointer which point to a memory location that is already deleted by some other pointer is called dangling pointer.


45)What is a Reference Variable in C++?

Answer:

reference variable is another variable having the same name.


46)What is a Storage Class? Mention the Storage Classes in C++.

Answer:

Storage classes describe the properties of variables and function.

type of storage class:

1-auto

2-register

3-mutable

4-static

5-extern


47)What is the keyword auto for?

Answer:

The keyword auto tells that the particular variable will not be accessible outside the function,all the local variables are called as auto variable because they are not accessible outside the block.


48)What is a template?

Answer:

template are present in c++,which provide us a feature to write a generic program.


49)What is Exception Handling? Does C++ support Exception Handling?

Answer:

Exception Handling is defined as the process in which we handle exception /error while executing the program.

yes c++ support exception handling.

try ,throw and catch block is used to handle exception in c++.


50) What is a Standard Template Library (STL)?

Answer:

STL stands for standard template library.it is a library in c++ which provide various data structure and function like vector,list,map,deque,set.


51)What are the various types of STL Containers?

Answer:

There are various type of STL Container-

1-Sequence Container

example: array,vector,list.

2-Associative Container

example: set,map,multimap.

3-Unordered Associative container

example: unordered_set,unordered_map.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments