top of page
  • Facebook
  • Twitter
  • Instagram

Top C-plus-plus Interview Questions

Mobiprep handbooks are free downloadable placement preparation resources that can help you ace any company placement process. We have curated a list of the 40 most important MCQ questions which are asked in most companies such as Infosys, TCS, Wipro, Accenture, etc. The placement handbooks also have detailed explanations for every question ensuring you revise all the questions with detailed answers and explanations.

Question

13

Explanation

Explain C++ structure.

structure is user defined data type that allows to combine data items of different kinds.
To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member. The format of the struct statement is as follows:

struct [structure tag]
{
member definition;
member definition;
...
} [one or more structure variables];

Example:
struct Books {
char title[50];
char author[50];
char subject[100];
int book_id;
} book;

To access any member of a structure, we use the member access operator (.)
Syntax: VariableName.MemberName

Question

14

Explanation

What is anyonamoyus structures in c++?

If a structure variable is defined while defining a structure then there is no need to name the structure. Such a structure is called as anyonamous structure.
Example:
struct
{ int rollno;
char name[20];
}a;
main()
{ cout<<"Enter the rollno,name=>";
cin>>a.rollno>>a.name;
cout<<"Rollno =”<< a.rollno<<” Name =”<< a.name;
}

Question

15

Explanation

What are classes and objects in C++?

CLASS: A class is a user defined datatype where we can bind its data and its related functions together.
A class is defined in terms of its data members and member function.
Data members indicate informations about objects or current state of objects. While, member function indicates operationwhich we can perform on an object.
Syntax:- class name
{
Data Members
-------
Member Function
--------
};

OBJECTS: A class provides the blueprints for objects, so basically an object is created from a class i.e. An object is an instance of class.

Question

16

Explanation

Define all OOPs concepts in C++.(Abstraction, Encapsuation, Inheritence, Polymorphism)

ABSTRACTION:
Abstraction is the concept of taking some object from the real world, and converting it to programming terms. Abstraction in Object Oriented Programming helps to hide the irrelevant details of an object.

ENCAPSULATION
Encapsulation in C++ is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as as single unit. In encapsulation the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class, therefore it is also known as data hiding.

INHERITENCE:
Inheritance is the ability, offered by many OOP languages, to derive a new class (the derived or inherited class) from another class (the base class). The derived class automatically inherits the properties and methods of the base class.

POLYMORPHISM
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.

bottom of page