CPP Interview Questions
CPP Interview Questions
answers
1) What is C++?
C++ is an object oriented programming language. It was developed by
Bjame Stroustrup in 1983 at the AT & T Bell Laboratories, Now Jersey, USA. It
is basically a super set of C, which provided low level features.
2) What are the basic concepts of OOP?
Objects
Classes
Data Abstraction and Encapsulation
Inheritance
Polymorphism
Dynamic Binding
Message Passing
3) What is oops?
An object oriented program is a collection of discrete objects, which are self
contained collections of both data structures and functions that interactwith
other objects.
4) What are the characteristic of C++ language?
Encapsulation
Inheritance
Polymorphism
7) What are the components of a class?
A class consists of two components data members andmethods.
8) What are methods?
Methods are functions associated with the class. They are able to access
even private data members.
9) What is the significance of class keyword in C++/Java?
The keyword class (in C++ and Java) specifies an Abstract Data Type (ADT).
ADTs expose operations that provide a higher level functionality, and the
lower level implementation details are isolated and hidden from the users of
the class.
10) What is the difference between source and escape sequences?
The source text is created with the help of source characters. These are
interpreted at execution time. The valuesof these characters are
implementation defined.
11) What are tokens?
The smallest individual units in a program are called tokens.
12) What are the types of tokens?
C++ has the following tokens are :
Keywords
Identifiers
Constants (literals)
Punctuators (Separators)
Operators
has
the
following
advantages
over
buffers and resources. The destruction of one object will not affect the other
object. Typically, we provide our own copy constructor and assignment
operator implementations for doing deep copy of objects.
51) What is a pointer?
A pointer is a variable which holds a memory address within.
Each variable is located at a particular position in the memory which is
known as
Address.
The address can be stored in a pointer.
A program accesses the value in the address stored in the pointer by
using indirection operator.
52) What is an expression?
An expression is any statement which is composed ofone or more operands
and returns a value. It may be combination of operators, variables and
constants.
asterisk and ends with the character sequence ("*/"), i.e. an asterisk followed
by a forward slash.
61) What is meant by two dimensional array?
A two dimensional array may be visualized as a table consisting of rows and
columns. Each cell of the table will denote an array element.
62) What is meant by multi dimensional array?
Multidimensional arrays are arrays with more than one dimension. An array
may consist of any number of dimensions, of course, subject to the
restrictions put by a compiler implementation within the scope of language
specifications.
63) What are the types of built in data types?
The built in data types available in C++ are :
Integral type
Floating type
Void
Integer constants
Character constants
Floating Point constants
String constants
Logical errors
74) What is string?
String is a series of characters. The string is enclosed within double quotes. A
string is used to write or store messages.
HELLO
75) What is the difference between errors and debugging?
Errors may be made during program creation even by experienced
programmers also. Such type of errors are detected by the Compiler.
Debugging means removing the errors.
76) What is a scope resolution operator?
The scope resolution operator permits a program to reference an identifier in
the global scope that has been hidden by another identifier with the
samename in the local scope.
77) What is multiple inheritance?
A class can inherit properties from more than one class which is known as
multiple inheritance.
the data structures like linked lists, double linked lists and trees. There is a
distinct difference between normal and recursive functions.
82) What is the difference between goto and unconditional goto?
The goto statement is used to alter the program execution sequence by
transferring the control to some other part of the program. The unconditional
goto statement is used just to transfer the control from one part of the
program to the other part without checking any condition. Normally, a good
programmer will not prefer to use the unconditional goto statement in his
programas it may lead to a very complicated problem like a never ending
process.
83) What is the difference between class and structure?
By default, the members ot structures are public while that tor class is
private.
Structures doesn't provide something like data hiding which is provided
by the classes.
Structures contains only data while class bind bothdata and member
functions.
84) What are design patterns?
Design patterns are reusable, extensible solutions to common design
problems faced by designers of object-oriented systems. Design patterns are
language neutral and are of a higher level of abstraction than code.
The functions that are declared with the keyword friend as friend
function.Thus, a friend function is an ordinary function or a member of
another class.
87) What is a call by reference?
A function call mechanism that passes arguments to a function by passing
the addresses of the arguments.
88) What is the call by value?
A function call mechanism that passes arguments to a function by passing a
copy of the value of the arguments.
89) What is inheritance?
The mechanism of deriving a new class from an old one is called inheritance.
The old class is referred to as the base class and the new one is called the
derived class or the sub class.
90) What are the types of inheritance?
Single inheritance
Multiple inheritance
Multi level inheritance
Hierarchical inheritance
Hybrid inheritance
Concrete classes can be instantiated (in other words, objects can be created
from concrete classes). These classes have no abstract methods. Concrete
classes are a logical complement of abstract classes.
94) What is class cohesion?
Cohesion indicates how closely the members are related to each other or
how strongly the members depend on each other in a class. Highly cohesive
classes or modules indicate good design.
95) What is class coupling?
Coupling means how two (or more classes) are dependent or strongly related
to each other. When two classes are tightly coupled, change in one class
usually requires change in the other class. Therefore, tightly coupled classes
are not recommended.
96) What is the difference between local and globalvariable?
Local variables Identifiers declared as label, const, type, variables and
functions in a block are said to belong to a particular block or function and
these identifiers arc known as the local parameters or variables. Local
variables are defined inside a function block or a compound statement.
Global variables are variables defined outside the main function block. These
variables are referred by the same data type and by the same namethrough
out the program in both the calling portion of a program and in the function
block. Whenever some of the variables are treated as constants in both the
main and the function block, it is advisable to use global variables.
97) What are the types of type modifiers?
There are four types of type modifiers are :
Signed
Long
Unsigned
Short
extern
static
register
auto