Top 99 interview questions and answers for C++| Part 2
Top 99 interview questions and answers for C++| Part 2
34.
Defining a new job for the existing operator w.r.t the class objects is called as operator overloading.
35.
What is function overloading? Defining several functions with the same name with unique list of parameters is called as function overloading. |
36.
What is the data type to store the Boolean value? bool, is the new primitive data type introduced in C++ language. |
37.
No, Defining a class/structure is just a type definition and will not allocated memory for the same.
38.
Dot (.) and Arrow ( -> )
39.
Name the data type which can be used to store wide characters in C++ wchar_t |
40.
Preprocessor is a directive to the compiler to perform certain things before the actual compilation process begins.
41.
A C++ program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol.
42.
What is a container class? A class containing at least one member variable of another class type in it is called so. |
43.
Every local variable by default being an auto variable is stored in stack memory
44.
Yes, it can be but cannot be executed, as the execution requires main() function definition.
45.
When should we use the register storage specifier? If a variable is used most frequently then it should be declared using register storage specifier, then possibly the compiler gives CPU register for its storage to speed up the look up of the variable. |
46.
The starting address of the array is called as the base address of the array.
47.
Used to resolve the scope of global symbol
|
1 2 3 4 5 6 7 8 9 10 11 12 |
<span class="com">#include</span> <span class="str"><iostream></span> <!--more--> <span class="kwd">using</span> <span class="kwd">namespace</span><span class="pln"> std</span><span class="pun">;</span><span class="pln"> main</span><span class="pun">()</span> <span class="pun">{</span> <span class="kwd">extern</span> <span class="kwd">int</span><span class="pln"> i</span><span class="pun">;</span><span class="pln"> cout</span><span class="pun"><<</span><span class="pln">i</span><span class="pun"><<</span><span class="pln">endl</span><span class="pun">;</span> <span class="pun">}</span> <span class="kwd">int</span><span class="pln"> i</span><span class="pun">=</span><span class="lit">20</span><span class="pun">;</span> |
48.
A static local variables retains its value between the function call and the default value is 0. The following function will print 1 2 3 if called thrice. (more…)
49.
By default every local variable of the function is automatic (auto). In the below function both the variables ‘i’ and ‘j’ are automatic variables. (more…)
50.
The catch block with ellipses as follows
|
1 2 3 |
<span class="kwd">catch</span><span class="pun">(…)</span> <span class="pun">{</span> <span class="pun">}</span> |
51.
A template class is a generic class. The keyword template can be used to define a class template.
52.
The arguments/parameters which are sent to the main() function while executing from the command line/console are called so. All the arguments sent are the strings only.
53.
A namespace is the logical division of the code which can be used to resolve the name conflict of the identifiers by placing them under different name space.
54.
The scope resolution operator is used to
- Resolve the scope of global variables.
- To associate function definition to a class if the function is defined outside the class.
55.
What is the role of the file opening mode ios::trunk? If the file already exists, its content will be truncated before opening the file. |
56.
A variable whose scope is applicable only within a block is said so. Also a variable in C++ can be declared anywhere within the block.
57.
Can we implement all the concepts of OOPS using the keyword struct? Yes. |
58.
By default the members of struct are public and by default the members of the class are private.
59.
This, is the pointer variable of the compiler which always holds the current active object’s address.
60.
Defining the functions within the base and derived class with the same signature and name where the base class’s function is virtual.
61.
No, exceptions can be handled whereas program cannot resolve errors.
62.
What happens if an exception is thrown outside a try block? The program shall quit abruptly. |
63.
Is it legal to assign a base class object to a derived class pointer? No, it will be error as the compiler fails to do conversion. |
64.
Not necessarily, a class having at least one pure virtual function is abstract class too.
65.
What is the difference between delete and delete[]? Delete[] is used to release the array allocated memory which was allocated using new[] and delete is used to release one chunk of memory which was allocated using new. |
66.
Public, private & protected
interviewquiz.net
No comments:
Post a Comment