x

Wednesday, January 27, 2016

Top 99 interview questions and answers for C++| Part 3

Top 99 interview questions and answers for C++| Part 3

9788177228045

These C++ Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of C++.

Top 99 interview questions and answers for C++

67.

What is the default function call method?

By default the functions are called by value.

68.

What is the maximum length of an identifier?

Ideally it is 32 characters and also implementation dependent.

69.

What is the first string in the argument vector w.r.t command line arguments?

Program name.

70.

What is recursion?

Function calling itself is called as recursion.

71.

What are valid operations on pointers?

The only two permitted operations on pointers are

  • Comparision ii) Addition/Substraction (excluding void pointers)

72.

How can we refer to the global variable if the local and the global variable names are same?

We can apply scope resolution operator (::) to the for the scope of global variable.

73.

Which operator can be used to determine the size of a data type/class or variable/object?

sizeof

74.

Who designed C++ programming language?

Bjarne Stroustrup.

75.

Can we resize the allocated memory which was allocated using ‘new’ operator?

No, there is no such provision available.

76.

Which compiler switch to be used for compiling the programs using math library with g++ compiler?

Opiton –lm to be used as > g++ –lm <file.cpp>

77.

What is reminder for 5.0 % 2?

Error, It is invalid that either of the operands for the modulus operator (%) is a real number.

78.

What are the different ways of passing parameters to the functions? Which to use when?

Call by value: We send only values to the function as parameters. We choose this if we do not want the actual parameters to be modified with formal parameters but just used.

(more…)

79.

What are command line arguments?

The arguments which we pass to the main() function while executing the program are called as command line arguments. The parameters are always strings held in the second argument (below in args) of the function which is array of character pointers. First argument represents the count of arguments (below in count) and updated automatically by operating system. (more…)

80.

What is a friend class?

A class members can gain accessibility over other class member by placing the class declaration prefixed with the keyword ‘friend’ in the destination class.

81.

What is the order of objects destroyed in the memory?

The objects are destroyed in the reverse order of their creation.

82.

What is a virtual destructor?

A virtual destructor ensures that the objects resources are released in the reverse order of the object being constructed w.r.t inherited object.

83.

Can we nest multi line comments in a C++ code?

No, we cannot.

84.

What is the purpose of #undef preprocessor?

It will be used to undefine an existing macro definition.

85.

Is 068 a valid octal number?

No, it contains invalid octal digits.

86.

Which key word is used to perform unconditional branching?

goto.

87.

What is the difference between variable declaration and variable definition?

Declaration associates type to the variable whereas definition gives the value to the variable.

88.

What is the difference between actual and formal parameters?

The parameters sent to the function at calling end are called as actual parameters while at the receiving of the function definition called as formal parameters.

89.

S++ or S=S+1, which can be recommended to increment the value by 1 and why?

S++, as it is single machine instruction (INC) internally.

90.

What is difference between including the header file with-in angular braces <> and double quotes “ “

If a header file is included with in < > then the compiler searches for the particular header file only with in the built in include path. If a header file is included with in “ “, then the compiler searches for the particular header file first in the current working directory, if not found then in the built in include path

91.

If a pointer declared for a class, which operator can be used to access its class members?

Arrow (->) operator can be used for the same

92.

What is the use of the keyword ‘using’?

It is used to specify the namespace being used in.

93.

What is ‘cin’?

cin is the object of istream class. The stream ‘cin’ is by default connected to console input device.

94.

What is ‘cout’?

cout is the object of ostream class. The stream ‘cout’ is by default connected to console output device.

95.

What is the full form of STL?

Standard template library

96.

What is ‘std’?

Default namespace defined by C++.

97.

Can we create and empty class? If so what would be the size of such object.

We can create an empty class and the object size will be 1.

98.

Are class functions taken into consideration as part of the object size?

No, only the class member variables determines the size of the respective class object.

99.

Which function is used to move the stream pointer for the purpose of reading data from stream?

seekg()

interviewquiz.net

Leave a Reply

No comments:

Post a Comment