Home »
MCQs
C++ MCQs (Multiple-Choice Questions)
C++ is a high-level, general-purpose computer programming language that supports all features of C language with the concepts of an object-oriented programming approach.
C++ Programming MCQs
C++ MCQs: This section contains multiple-choice questions and answers on the various topics of C++ Programming. Practice these MCQs to test and enhance your skills on C++ Programming.
List of C++ Multiple-choice Questions and Answers
1. C++ language was developed by ___.
- Dennis Rechard
- Dennis M. Ritchie
- Bjarne Stroustrup
- Anders Hejlsberg
Answer: C) Bjarne Stroustrup
Explanation:
C++ programming language was developed by Bjarne Stroustrup at Bell Laboratories (formerly AT&T Bell Laboratories).
Discuss this Question
2. In which year, the name of the language was changed from "C with Classes" to C++?
- 1979
- 1972
- 1983
- 1986
Answer: C) 1983
Explanation:
In 1983, the name of the language was changed from "C with Classes" to C++.
Discuss this Question
3. C++ language is a successor to which language?
- B
- C
- Java
- VB
Answer: B) C
Explanation:
C++ is a successor of C language.
Discuss this Question
4. C++ language is a ___.
- Object Oriented Language
- Procedural Oriented Language
- Structural Oriented Language
- None of the above
Answer: A) Object Oriented Language
Explanation:
C++ is an object-oriented language. It supports the concept of OOPs.
Discuss this Question
5. C++ follows ___.
- Top-Down Design approach
- Bottom-Up Design approach
- Both of the above
- None of the above.
Answer: B) Bottom-Up Design approach
Explanation:
C++ follows a bottom-up design approach for development.
Discuss this Question
6. C++ is a ___.
- High-level language
- Medium level language
- Low-level language
- None of the above
Answer: B) Medium level language
Explanation:
C++ is a medium-level language because it contains the features of low-level language as well as high-level language (Low-level Vs High-level).
Discuss this Question
7. How many keywords are in C++?
- 32
- 48
- 99
- 95
Answer: D) 95
Explanation:
Keywords are also known as reserved words, there are 95 keywords are available in C++. Some of the C++ keywords are not available in the C language.
Discuss this Question
8. Which of the following is not a valid keyword in C++ language?
- while
- for
- switch
- do-while
Answer: D) do-while
Explanation:
Do-while is a control statement, here "do" and "while" are different keywords.
Discuss this Question
9. Which of the following statement is correct about identifiers in C++?
- Identifiers are the combination of alphanumeric characters that can be used for function and variable names.
- Identifiers are a combination of alphanumeric characters that can be used for looping statements.
- Both of the above
- None of the above
Answer: A) Identifiers are the combination of alphanumeric characters that can be used for function and variable names.
Explanation:
The 2nd statement is correct about identifiers in C++.
Discuss this Question
10. Which of the following is used for single-line comment in C++?
- //
- \\
- /* */
- ##
Answer: A) //
Explanation:
We use "//" for single-line comments in C++.
Discuss this Question
11. Which of the following is used for multi-line comments in C++?
- //
- \\
- /* */
- ##
Answer: C) /* */
Explanation:
We use "/* */" for multi-line comment in C++.
Discuss this Question
12. In C++, can we put comments between the statement?
- True
- False
Answer: A) True
Explanation:
Yes, we can put comments between the statement in C++ language.
C = A /*2+3*/ + B;
Discuss this Question
13. In which year C++14 was introduced?
- 2014
- 2015
- 2017
- None of the above
Answer: A) 2014
Explanation:
C++14 was introduced in 2014. It contains the following features:
- polymorphic lambdas
- digit separators
- generalized lambda capture
- variable templates
- binary integer literals
- quoted strings
Discuss this Question
14. Which of the following language translator is used in C++?
- Assembler
- Interpreter
- Compiler
- Both Interpreter and Compiler
Answer: C) Compiler
Explanation:
In C++, a Compiler is used to process C++ source files and generate object files.
Discuss this Question
15. Which of the following whitespace characters can be used in C++?
- Horizontal tab
- Vertical tab
- Form feed
- New line
Options:
- 1 and 2
- 3 and 4
- 1, 3, 4
- All 1,2,3,4
Answer: D) All 1,2,3,4
Explanation:
In C++, we can use the following whitespace characters:
- Space
- Horizontal tab
- Vertical tab
- Form feed
- New-line
Discuss this Question
16. Which of the following is the correct extension of the C++ source code file?
- .cpp
- .c++
- Both
- None
Answer: c) Both
Explanation:
We can use both ".cpp" and ".c++" for a C++ source code file.
Discuss this Question
17. Which of the following command is used for the C++ compiler in Linux OS?
- GCC
- c++
- g++
- None
Answer: C) g++
Explanation:
The g++ command is used to compile C++ source files.
Discuss this Question
18. C++ is a pure object-oriented language.
- True
- False
Answer: B) False
Explanation:
C++ is not a pure object-oriented language because it supports the oops concept as well as procedural-oriented features.
Discuss this Question
19. C++ supports automatic garbage collection?
- True
- False
Answer: B) False
Explanation:
C++ does not support automatic garbage collection. Here we need to free dynamically allocated memory using free() or delete. Otherwise, it may cause memory leaks.
Discuss this Question
20. C++ is case sensitive language?
- True
- False
Answer: A) True
Explanation:
Yes, C++ is a case-sensitive language. Here Var1 and var1 will treat differently.
Discuss this Question
21. Which of the following OOPs concepts are supported in C++?
- Inheritance
- Encapsulation
- Abstraction
- Polymorphism
Opation:
- 1 and 2
- 1, 2, and 3
- 1, 2, and 4
- All 1,2,3,4
Answer: D) All 1,2,3,4
Explanation:
C++ supports the following OOPS concept:
- Inheritance
- Encapsulation
- Abstraction
- Polymorphism
Discuss this Question
22. OOPs stands for?
- Object Oriented Process System
- Object Oriented Programming System
- Object Oriented Programming Service
- Object Orientation Programming System
Answer: B) Object Oriented Programming System
Explanation:
OOPs stands for Object Oriented Programming System.
Discuss this Question
23. Is it true, C++ is a superset of C language?
- True
- False
Answer: A) True
Explanation:
Yes, C++ is known as a superset of C. Because C++ supports almost all the features of C language.
Discuss this Question
24. C++ is a more secure programming language compared to C language?
- True
- False
Answer: A) True
Explanation:
Yes, C++ is a more secure programming language compared to C language because C language does not support encapsulation and information hiding.
Discuss this Question
25. Stream is ___.
- Group of non-printable character
- Sequence of bytes
- Set of errors
- The flow of invalid characters
Answer: A) Group of non-printable character
Explanation:
In C++, we use the stream concept for Input/Output operations. It is a sequence of bytes or flow of data that improves performance.
Discuss this Question
26. If the set of bytes flows from main memory to other devices like printers, the monitor is known as ___.
- Input Operation
- Output Operation
- Both of above
- None of the above
Answer: B) Output Operation
Explanation:
If the set of bytes flows from the main memory to other devices like the printer, the monitor is known as output operation.
Discuss this Question
27. Which of the following header file is used to define cin, cout?
- <iomanip.h>
- <iostream.h>
- <fstream.h>
- None of the above
Answer: B) <iostream.h>
Explanation:
The <iostream.h> header file is used to define cin and cout.
Discuss this Question
28. The cin, cout are ___.
- Library functions
- structures
- Pointers
- objects
Answer: D) objects
Explanation:
The cin and cout are the objects of the istream and ostream classes respectively that are used to perform input/output operations.
Discuss this Question
29. Which of the following is not a valid predefined object in C++?
- cin
- cout
- cput
- cerr
Answer: C) cput
Explanation:
The "cput" is not a valid predefined object in C++.
Discuss this Question
30. The stdout stands for ___.
- State Output
- Standard Output
- Stand Output
- Stream Output
Answer: B) Standard Output
Explanation:
The "stdout" stands for standard output. It is used to represent standard output devices like the monitor.
Discuss this Question
31. Is it true, the cerr is an object of the ostream class?
- True
- False
Answer: A) True
Explanation:
Yes, it is true, the cerr is an object of the ostream class, which is used to output the errors.
Discuss this Question
32. Which of the following is an insertion operator in C++?
- <<
- >>
- ->
- <<<
Answer: A) <<
Explanation:
In C++, "<<" is known as the insertion operator which is used with the "cout" object to print data on the console screen.
Discuss this Question
33. Which of the following is an extraction operator in C++?
- >>>
- >>
- ->
- <<<
Answer: B) >>
Explanation:
In C++, ">>" is known as an extraction operator which is used with the "cin" object to read user input.
Discuss this Question
34. The endl is a ___.
- Macro
- object
- Pointers
- function
Answer: A) Macro
Explanation:
The endl is an object of ostream classes, which is used to print newline on the console screen.
Discuss this Question
35. Which of the following object is also used to flush the stream?
- cin
- cout
- cerr
- endl
Answer: D) endl
Explanation:
The "endl" object is used to print the newline as well as flush the stream.
Discuss this Question
36. Which of the following namespace contains cin, cout objects?
- ost
- std
- endl
- none of the above
Answer: B) std
Explanation:
The "std" namespace contains cin, and cout objects.
Discuss this Question
37. Which of the following are types of datatypes in C++?
- Basic Datatype
- Derived Datatype
- Enumeration data type
- User Defined datatype
Options:
- 1 and 2
- 1, 2, and 4
- 1, 2, and 3
- All, 1, 2, 3, 4
Answer: D) All, 1, 2, 3, 4
Explanation:
There are 4 types of datatypes in C++:
- Basic Datatype
- Derived Datatype
- Enumeration data type
- User Defined datatype
Discuss this Question
38. The size of basic datatypes can be changed according to 32 or 64-bit operating systems?
- True
- False
Answer: A) True
Explanation:
Yes, it is true, the size of basic datatypes can be changed according to 32 or 64-bit operating systems.
Discuss this Question
39. If we use value "3.14" then what will be the data type of the given value?
- float
- double
- long double
- none of the above
Answer: B) double
Explanation:
If we use any floating-point value with the suffix "F" in C++ that will be double type.
Discuss this Question
40. Which of the following is the correct format specifier for long double-type values in C++?
- %f
- %ld
- %lf
- %ldf
Answer: C) %lf
Explanation:
The "%lf" format specifier is used for long double in C++.
Discuss this Question
41. What is the size of a long double in C++?
- 8 bytes
- 10 bytes
- 12 bytes
- 16 bytes
Answer: B) 10 bytes
Explanation:
The size of a long double in C++ is 10 bytes.
Discuss this Question
42. Is C++ language supports both signed and unsigned literals?
- True
- False
Answer: A) True
Explanation:
Yes, C++ supports both signed and unsigned literals.
Discuss this Question
43. Which of the following is not the basic type in C++?
- int
- float
- array
- char
Answer: C) array
Explanation:
The "array" is a derived datatype in C++. It is not a fundamental datatype in C++.
Discuss this Question
44. Can we create a character variable that will occupy more than 1 byte in memory?
- True
- False
Answer: A) True
Explanation:
Yes, in C++, using wchar_t we can declare a variable that will occupy more than 1 byte of memory space.
Discuss this Question
45. For which type, the format specifier "%i" is used?
- int
- float
- array
- char
Answer: A) int
Explanation:
We can use a "%d" or "%i" format specifier for integer variables in C++.
Discuss this Question
46. Which of the following is not a correct qualifier in C++?
- Size qualifier
- Type qualifier
- Sign qualifier
- None of the above
Answer: D) None of the above
Explanation:
There are 3 types of qualifiers used in C++:
- Size qualifier
- Sign qualifier
- Type qualifier
Discuss this Question
47. By default, "int" is?
- Signed integer
- Unsigned integer
Answer: A) Signed integer
Explanation:
In C++, "int" is a signed integer.
Discuss this Question
48. The data type "short" and "short int" are similar in C++?
- True
- False
Answer: A) True
Explanation:
"short" and "short int" are similar types in C++.
Discuss this Question
49. How many byte(s) does a short type take in C++?
- 1
- 2
- 3
- 4
Answer: B) 2
Explanation:
In C++, the short or short int takes 2 bytes (16 bits) in memory.
Discuss this Question
50. The operator '+' is?
- Unary Operator
- Binary Operator
- Both Unary and Binary
- None of the above
Answer: C) Both Unary and Binary
Explanation:
In C++, the operator '+' can be used as a binary and unary operator.
Discuss this Question
51. The operator '%' is known as?
- Division Operator
- Modulus Operator
- Percentage Operator
- None of the above
Answer: B) Modulus Operator
Explanation:
In C++, the operator '%' is known as the modulus operator, which is used to find the remainder.
Discuss this Question
52. Which of the following operator is a ternary operator?
- +=
- !=
- ::
- ?:
Answer: D) ?:
Explanation:
In C++, the operator '?:' is a ternary operator, it operates on 3 operands, it is also known as a conditional operator.
Discuss this Question
53. Which of the following operator is known as Scope Resolution Operator?
- ::
- ?:
- ->
- .
Answer: A) ::
Explanation:
In C++, the operator '::' is known as the Scope Resolution operator.
Discuss this Question
54. Which of the following operator is known as Referential Operator?
- !=
- ?:
- ->
- sizeof
Answer: C) ->
Explanation:
In C++, the operator '->' is known as the Referential operator.
Discuss this Question
55. The sizeof() is a?
- Unary Operator
- Binary Operator
- Ternary Operator
- None of the above
Answer: A) Unary Operator
Explanation:
In C++, the sizeof() is a unary operator.
Discuss this Question
56. The associativity of unary operators is?
- Left to Right
- Right to Left
Answer: B) Right to Left
Explanation:
In C++, the associativity of unary operators is Right to Left.
Discuss this Question
57. The associativity of the "[]" operator is?
- Left to Right
- Right to Left
Answer: A) Left to Right
Explanation:
In C++, the associativity of the "[]" operator is Left to Right.
Discuss this Question
58. The associativity of the conditional operator is?
- Left to Right
- Right to Left
Answer: B) Right to Left
Explanation:
In C++, the associativity of the conditional operator "?:" is Right to Left.
Discuss this Question
59. Which of the following operator is used to return the address of a variable?
- *
- ->
- &
- None of the above
Answer: C) &
Explanation:
In C++, the "&" operator is used to return the address of a variable.
Discuss this Question
60. Which of the following is known as the "value of" operator?
- *
- ->
- &
- None of the above
Answer: A) *
Explanation:
In C++, the "*" operator is known as the "value of" operator.
Discuss this Question
61. Which of the following is known as the "NOT" operator?
- ~
- !
- NOT
- None of the above
Answer: B) !
Explanation:
In C++, the "!" operator is known as the "NOT" operator.
Discuss this Question
62. Which of the following is not an arithmetic operator?
- %
- /
- !
- *
Answer: C) !
Explanation:
In C++, the "!" operator is not an arithmetic operator, it is a logical operator.
Discuss this Question
63. Which of the following statement is correct about the global variable?
- A variable defined inside the function or block is known as a global variable.
- A variable defined outside the function or block is known as a global variable.
- Global variables can only declare inside the “.h” file.
Answer: B) A variable defined outside the function or block is known as a global variable.
Explanation:
The 2nd statement is correct about the global variable.
Discuss this Question
64. The system automatically initializes a local variable?
- True
- False
Answer: B) False
Explanation:
The system automatically initializes a global variable whereas we need to initialize local variables explicitly.
Discuss this Question
65. The default value of a variable that is declared using register storage class?
- 0
- Garbage
Answer: B) Garbage
Explanation:
The default value of the variable, which is declared using the register storage class is garbage.
Discuss this Question
66. Which of the following is the default storage class in C++?
- auto
- extern
- register
- static
Answer: A) auto
Explanation:
The "auto" is the default storage class in C++.
Discuss this Question
67. The "mutable" is a storage class in C++?
- True
- False
Answer: A) True
Explanation:
Yes, "mutable" is a storage class in C++.
Discuss this Question
68. Which of the following escape sequence is used to print double quotes on the console screen?
- %”
- /”
- *”
- None of the above
Answer: B) /”
Explanation:
The escape sequence /" prints double quotes on the console screen.
Discuss this Question
69. Which of the following escape sequence is used to print the percentage symbol on the console screen?
- %%
- /%
- *%
- None of the above
Answer: A) %%
Explanation:
The escape sequence %% is used to print the percentage symbol on the console screen.
Discuss this Question
70. Which of the following statement is correct about default arguments?
- Arguments that cannot be passed to the function
- Arguments with a default value that is not mandatory to be passed into the function
- Arguments that always take the same data value
- None of the above
Answer: B) Arguments with a default value that is not mandatory to be passed into the function
Explanation:
In C++, we can create functions with default arguments. The default arguments are used with a default value that is not mandatory to be passed into the function.
Discuss this Question
71. Which of the following condition is correct for the default arguments?
- Default arguments must be the last arguments in the function declaration.
- Default arguments must be the first argument in the function declaration.
- Default arguments can be declared anywhere in the function declaration.
- None of the above
Answer: A) Default arguments must be the last arguments in the function declaration.
Explanation:
In C++, we can create functions with default arguments. The default arguments must be the last argument in the function declaration.
Discuss this Question
72. Which of the following function can be called without any arguments?
- int print(int count, char ch='*')
- int print(char ch='*')
- int print(char ch='*',int count)
- int print(char ch)
Answer: B) int print(char ch='*')
Explanation:
In the above options, option B is correct.
Discuss this Question
73. Which of the following is the correct function prototype?
- void printchar(int cnt=0, char ch, int val=0)
- void printchar(int cnt=0, char='*')
- void printchar(int cnt, char ch='*')
- void printchar(char ch='c', int cnt)
Answer: C) void printchar(int cnt, char ch='*')
Explanation:
In the above options, option C is correct.
Discuss this Question
74. Which of the following function will be called with the independent syntax "sample(10,20,30);"?
- void sample(int x, int y)
- void sample(int x=0, int y, int z)
- float sample(int x=0, y=0, z=0)
- void sample(int x, int y, int z=0)
Answer: D) void sample(int x, int y, int z=0)
Explanation:
In the above options, option D is correct. Option C is incorrect because the return type is "float" and the syntax given is independent which means it doesn't return any value.
Discuss this Question
75. Which of the following is an incorrect call to the function void sample(int a, int b=0, int c=0)?
- sample(10,20,30);
- sample();
- sample(50);
- sample(30,40);
Answer: B) sample();
Explanation:
Here we need to pass at least one argument to the function.
Discuss this Question
76. Which of the following statement is correct about Default arguments?
- Default arguments are allowed in the argument list of the function declaration.
- Default arguments are allowed in the return type of the function declaration.
- Default arguments are allowed with the class name definition.
- Default arguments are allowed with floating-point type values.
Answer: A) Default arguments are allowed in the argument list of the function declaration.
Explanation:
Default arguments are allowed in the argument list of the function declaration.
Discuss this Question
77. Which of the following statement is not correct about Default arguments?
- Default arguments are allowed with pointer and reference to function declaration.
- Default arguments are not allowed with a declaration of a pointer to functions.
- Default arguments are not allowed with the reference to functions.
- None of the above
Answer: A) Default arguments are allowed with pointer and reference to function declaration.
Explanation:
Default arguments are not allowed with pointer and reference to function declaration.
Discuss this Question
78. The default argument gets bound during declaration but is executed during the function call?
- True
- False
Answer: A) True
Explanation:
Yes, the default argument gets bound during declaration but is executed during the function call.
Discuss this Question
79. Can we implement a constructor with a default argument?
- True
- False
Answer: A) True
Explanation:
Yes, we can implement a constructor with a default argument.
Discuss this Question
80. How many sequences of statements are available in C++?
- 6
- 5
- 4
- 3
Answer: B) 5
Explanation:
There are following sequence of statements is available in C++:
- Pre-processor directives
- Comments
- Declarations
- Function Declarations
- Executable statements
Discuss this Question
81. Which of the following is/are a decision making statement?
- IF statements
- Switch statement
- Conditional operators
- None of the above
Options:
- 1 and 2
- 1 and 3
- 4
- 1, 2, and 3
Answer: D) 1, 2, and 3
Explanation:
In C++, Decision-making statements are:
- IF statements
- Switch Statements
- Conditional operators.
Discuss this Question
82. Which of the following statement can replace the if-else statement?
- while loop
- do-while loop
- for loop
- conditional operator
Answer: D) conditional operator
Explanation:
In C++, we can replace if-else statements using conditional operators.
Discuss this Question
83. Which of the following is the best option to make decisions for multiple choices?
- if
- if-else
- if-else-if
- All the above
Answer: C) if-else-if
Explanation:
In C++, "if-else-if" is the best option for multiple choices.
Discuss this Question
84. Can we use the string in the Switch statement for case selection?
- True
- False
Answer: B) False
Explanation:
In C++, we cannot use the string in Switch stamen for case selection.
Discuss this Question
85. Which of the following is an entry control loop?
- While Loop
- Do While loop
Answer: A) While Loop
Explanation:
While loop is an entry control loop, in a "while" loop we need to check the condition before executing the loop body.
Discuss this Question
86. Which of the following is an exit control loop?
- While Loop
- Do While loop
- For loop
- None of the above
Answer: B) Do While loop
Explanation:
The do-while loop is an entry control loop, in the "while" loop we need to check the condition before executing the loop body.
Discuss this Question
87. Which of the following loop is normally used for a menu-driven program?
- Do While loop
- For loop
- While loop
- None of the above
Answer: A) Do While loop
Explanation:
The do-while loop is used for a menu-driven program in C++.
Discuss this Question
88. Which of the following loop, in which we have to execute the body of the loop before checking the condition?
- Do While loop
- For loop
- While loop
- None of the above
Answer: A) Do While loop
Explanation:
In the Do-while loop, we have to execute the body of the loop before checking the condition.
Discuss this Question
89. Which of the following types of variables can be used in the Switch statement for case selection?
- int, float, char
- int, char
- int, double
- Any fundamental type
Answer: A) int, float, char
Explanation:
We can use only int, char type variables in the switch statement for case selection.
Discuss this Question
90. In switch statements, Expression in parenthesis "( )" after the switch statement is mandatory?
- True
- False
Answer: A) True
Explanation:
Yes, the Expression in parenthesis "()" after the switch statement is mandatory.
Discuss this Question
91. Which of the following statement is correct about the "break" statement?
- The break statement cancels the remaining iterations
- Break statement skips a particular iteration
- The break statement terminates the program
- None of the above
Answer: A) The break statement cancels the remaining iterations
Explanation:
The Break statement cancels the remaining iterations.
Discuss this Question
92. Which of the following loop is faster in C++?
- Do While loop
- For loop
- While loop
- All loops work at the same speed
Answer: D) All loops work at the same speed
Explanation:
All loops work at the same speed.
Discuss this Question
93. Which of the following statement is used to quit the loop immediately?
- continue
- break
- while
- None of the above
Answer: B) break
Explanation:
The break statement is used to quit the loop immediately.
Discuss this Question
94. Which of the following statement is also known as a "switch" statement?
- selective statement
- choose statement
- bitwise statement
- certain statement
Answer: A) selective statement
Explanation:
The switch statement is also known as the selective statement.
Discuss this Question
95. Which of the following statement is also known as a "continue" statement?
- goto statement
- bitwise statement
- skipping statement
- certain statement
Answer: C) skipping statement
Explanation:
The "continue" statement is also known as the skipping statement.
Discuss this Question
96. Which of the following is the correct syntax of the "for" loop?
- for(condition; increment; declaration){ //body of the loop };
- for(declaration; increment/decrement; condition){ //body of the loop };
- for(initalization; condition; increment/decrement){ //body of the loop };
- None of the above
Answer: C) for(initalization; condition; increment/decrement){ //body of the loop };
Explanation:
The 3rd option is correct.
Discuss this Question
97. Which of the following is the correct syntax of the "do-while" loop?
- do{ //Body of the loop }while(condition);
- dowhile(condition){ //Body of the loop };
- do while(condition){ //Body of the loop };
- do{ //Body of the loop }while(condition)
Answer: A) do{ //Body of the loop }while(condition);
Explanation:
The 1st option is correct.
Discuss this Question
98. Which of the symbol is used with the label in the "goto" statement?
- @
- :
- #
- !
Answer: B) :
Explanation:
The colon ":" symbol is used with the label in the "goto" statement.
Discuss this Question
99. Which of the following loop is the best option when the number of iterations is known?
- While loop
- For loop
- Do while loop
- all loops require that the iterations be known
Answer: B) For loop
Explanation:
The "for" loop is the best option when the number of iterations is known.
Discuss this Question
100. Execution of C++ program starts from?
- void function
- class
- main function
- user-defined function
Answer: C) main function
Explanation:
Execution of the C++ program starts from the main () function.
Discuss this Question
101. Which of the following given option is used to complete the function declaration?
- Semicolon
- Colon
- Comma
- None of the above
Answer: C) Comma
Explanation:
The semicolon is used to complete the function declaration.
Discuss this Question
102. How many arguments can be passed to a function?
- 128
- 256
- 512
- Vary from compiler to compiler
Answer: D) Vary from compiler to compiler
Explanation:
It varies from compiler to compiler and also different C99 and C++ standards.
Discuss this Question
103. Which of the following are the mandatory part of the function prototype?
- Function name and argument list
- Function name and return type
- Function name, argument list, and return type
- Return type and argument list
Answer: B) Function name and return type
Explanation:
The function name and return type are the mandatory part of the function prototype.
Discuss this Question
104. What will be the output of the following program?
#include <iostream>
using namespace std;
void sayHello();
{
cout << "Hello World";
}
int main()
{
sayHello();
return 0;
}
Options:
- Hello World
- Hello
- Error
- None of the above
Answer: B) CSS
Explanation:
The above program will generate a syntax error because we use a semicolon in the definition of the sayHello() function. The correct program is given below:
#include <iostream>
using namespace std;
void sayHello()
{
cout << "Hello World";
}
int main()
{
sayHello();
return 0;
}
Discuss this Question
105. Can we use the return type void in the main() function in a C++ program?
- Yes
- No
Answer: B) NO
Explanation:
No, we cannot use the return type void in the main () function, we have to use the return type "int" with the main() function.
Discuss this Question
106. Which of the following is a more effective way to call a function with arguments?
- Call by value
- Call by reference
- Call by address
- None of the above
Answer: B) Call by reference
Explanation:
The "call by reference" is a more effective way to call a function with arguments because it reduces the overall time and memory use.
Discuss this Question
107. How many minimum numbers of functions are required to execute a C++ program?
- 1
- 2
- 3
- 4
Answer: A) 1
Explanation:
To execute a C++ program, we required only 1 function which is the main() function. Because the main() function is the entry point for the program.
Discuss this Question
108. What is the lifetime of a static variable declared in a user-defined function?
- Within the function only
- Within the main function only
- Whole program
- None of the above
Answer: C) Whole program
Explanation:
The lifetime of a static variable is in the whole program. But its scope is within the function only.
Discuss this Question
109. Which of the following statement is correct about inline function?
- A function that is substituted at the place of call.
- A function that is called at compile time
- A function that contains only looping statements
- None of the above
Answer: A) A function that is substituted at the place of call.
Explanation:
A function that is substituted at the place of call is called an inline function.
Discuss this Question
110. A function that is defined inside a class without any complex statement will be inline.
- True
- False
Answer: A) True
Explanation:
Yes, A function that is defined inside a class without any complex statement will be inline.
Discuss this Question
111. An inline function is substituted at the place of function call during?
- Compile Time
- Runtime
Answer: A) Compile Time
Explanation:
An inline function is substituted at the place of the function call during compile time.
Discuss this Question
112. A recursive function can be inline?
- Yes
- No
Answer: B) NO
Explanation:
A recursive function can never be inline in C++.
Discuss this Question
113. An inline function can contain static variables?
- Yes
- No
Answer: B) NO
Explanation:
An inline function cannot contain static variables.
Discuss this Question
114. An inline function is faster than a normal function?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, an inline function is faster than a normal function because it does not require a context switch from function call to function definition.
Discuss this Question
115. Default values for a function are defined.
- In function declaration
- In function definition
- During function call
- None of the above
Answer: A) In function declaration
Explanation:
We can define default values for a function in the function declaration.
Discuss this Question
116. Can we define the inline function outside the class in C++ program?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can define an inline function inside or outside the class.
Discuss this Question
117. Can we access the elements of an array outside the bound?
- Yes
- No
Answer: B) NO
Explanation:
No, we cannot access the elements of an array outside the bound in C++. It can generate logical and runtime errors.
Discuss this Question
118. Index of an array starts from?
- 1
- 2
- 0
- -1
Answer: C) 0
Explanation:
The index of an array starts from 0 in C++.
Discuss this Question
119. In C++, the Array name denotes?
- The base address of the array
- The first value of the array
- Last value of the array
- None of the above
Answer: A) The base address of the array
Explanation:
Array name denotes the base address of the array.
Discuss this Question
120. If we create an array "Arr", which is the correct way to access the first element of the array?
- Arr[0]
- 0[Arr]
- *(Arr+0)
- All the above
Answer: D) All the above
Explanation:
All the given options are the correct way to access the first element of the array.
Discuss this Question
121. Can we create an array of objects in C++?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can create an array of objects in C++.
Discuss this Question
122. Can we create the 4-dimensional array in C++?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can create a 4-dimensional array using the below statement.
int arr[2][2][2][2];
Discuss this Question
123. An array occupies memory space in?
- Contiguous manner
- Fragmented manner
- Linked List
- None
Answer: A) Contiguous manner
Explanation:
In C++, an array occupies memory space in a contiguous manner.
Discuss this Question
124. How many dimensions are an array in C++?
- 1D array
- 2D Array
- 3D array
- No Limit
Answer: D) No Limit
Explanation:
There is no limit of dimensions for arrays in C++.
Discuss this Question
125. When we pass an array to the function, then the function call will be?
- Call by value
- Call by reference
- Both A and B
- None of these
Answer: B) Call by reference
Explanation:
When we pass an array to the function then the function call will be "call by reference".
Discuss this Question
126. Which of the following statement is correct about the is_array() function in C++??
- The is_array() function is used to check whether a variable is an array or not.
- The is_array() function is used to check whether a variable is a 1D array or not.
- The is_array() function is used to check whether a variable is a 1D or 2D array.
- None of these
Answer: A) The is_array() function is used to check whether a variable is an array or not.
Explanation:
The is_array() function is used to check whether a variable is an array or not.
Discuss this Question
127. Which of the following statement is correct about the is_same() function in C++?
- The is_same() function is used to check whether a variable is an array or not.
- The is_same() function is used to check if two variables of array type.
- The is_same() function is used to check if two variables have the same characteristics.
- None of these
Answer: C) The is_same() function is used to check if two variables have the same characteristics.
Explanation:
The is_same() function is used to check if two variables have the same characteristics.
Discuss this Question
128. Which of the following function is used to get the dimensions of the given array?
- getdimension
- getarraydimension
- rank
- arrayrank
Answer: C) rank
Explanation:
The rank function is used to get the dimensions of the given array.
Discuss this Question
129. Which of the following function is used to remove all dimensions from an array?
- remove_dimension
- remove_all_dimensions
- remove_extent
- remove_all_extents
Answer: D) remove_all_extents
Explanation:
The remove_all_extents is used to remove all dimensions from an array.
Discuss this Question
130. Which of the following contains an array type manipulation function?
- std namespace
- <iostream>
- <array>
- None of the above
Answer: A) std namespace
Explanation:
The "std" namespace contains an array type manipulation function.
Discuss this Question
131. Is it true, when array initialization is part of the definition then the size of the array is not required?
- True
- False
Answer: A) True
Explanation:
Yes, the size of the array is not required when we initialize an array as part of the definition.
Discuss this Question
132. Which of the following operator is known as the indirection operator?
- ->
- &
- *
- None of the above
Answer: C) *
Explanation:
The "*" operator is known as the indirection operator in C++.
Discuss this Question
133. Which of the following operator is known as a referential operator?
- ->
- &
- *
- None of the above
Answer: A) ->
Explanation:
The "->" operator is known as a referential operator in C++.
Discuss this Question
134. Which of the following is invalid?
- string str, *ptr=0;
- int a, float *f = &a;
- int *ptr;
- None of the above
Answer: B) int a, float *f = &a;
Explanation:
The 2nd option is invalid because we are trying to initialize the address of the integer variable to a float pointer.
Discuss this Question
135. Can we point to a datatype using a pointer?
- True
- False
Answer: B) False
Explanation:
No, we cannot point to a datatype using a pointer.
Discuss this Question
136. Which of the following is the incorrect way to declare a pointer?
- int *ptr;
- int* ptr;
- int &ptr;
- int *ptr=0;
Answer: C) int &ptr;
Explanation:
The 3rd option is the incorrect way to declare a pointer.
Discuss this Question
137. A pointer can be initialized with?
- Address of variable of the same type
- NULL
- 0
- All the above
Answer: D) All the above
Explanation:
A pointer can be initialized with the address of a variable of the same type, NULL, and zero.
Discuss this Question
138. Which of the following is the correct way to get value from pointer "ptr"?
- ptr
- &ptr
- *ptr
- All the above
Answer: C) *ptr
Explanation:
The "*ptr" is the correct way to get the value from the pointer ptr.
Discuss this Question
139. What is the size of a pointer?
- 4 bytes
- 8 bytes
- 16 bytes
- Vary from processor to processor
Answer: D) Vary from processor to processor
Explanation:
The size of the pointer is varied from processor to processors like 16-bit, 32-bit, and 64-bit processors.
Discuss this Question
140. Which of the following is the correct option?
int* a, b;
- a is a pointer to an integer and b is an integer variable
- b is a pointer to an integer and a is an integer variable
- both a and b are pointers.
Answer: A) a is a pointer to an integer and b is an integer variable
Explanation:
In the above-given statement, a is a pointer to an integer and b is an integer variable.
Discuss this Question
141. Can we create a pointer to point a file in C++?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can create a pointer to point a file in c++ using the "FILE*" type.
Discuss this Question
142. What will be the output of the following program?
#include <iostream>
using namespace std;
int main()
{
int x = 50, y = 20;
int *p1 = &x, *p2 = &y;
p1 = p2;
cout << *p1;
return 0;
}
Options:
- 50
- 20
- Address
- Error
Answer: B) Address
Explanation:
Here, initially, pointer p1 points to variable x, and pointer p2 points to y variable. Then pointer p2 is assigned to pointer p1. So when we print *p2 then it will print the value of variable "y" which is 20.
Discuss this Question
143. A wild pointer is also known as a dangling pointer?
- Yes
- No
Answer: B) No
Explanation:
An uninitialized pointer is known as a wild pointer while a dangling pointer points to a location that has been deleted.
Discuss this Question
144. Which of the following can point to any type of variable?
- Far pointer
- Null pointer
- Void pointer
- Dangling pointer
Answer: C) Void pointer
Explanation:
A void pointer can point to any type of variable, to access value from a void pointer we need to typecast it.
Discuss this Question
145. What is the size of a far pointer?
- 16-bit
- 32-bit
- 64-bit
- None of the above
Answer: B) 32-bit
Explanation:
The size of a far pointer is 32-bit.
Discuss this Question
146. Can we access memory outside the current segment using a far pointer?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can access memory outside the current segment using a far pointer.
Discuss this Question
147. Which of the following is the incorrect type of pointer in C++?
- Near
- Far
- Huge
- Small
Answer: D) Small
Explanation:
The small pointer is the incorrect type of pointer in C++.
Discuss this Question
148. In Smart pointer, we did not require to take care to deallocate memory space?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, In smart pointers we did not require to take care to deallocate memory space, allocated memory will be free automatically.
Discuss this Question
149. Which of the following is not the correct type of smart pointer?
- unique_ptr
- shared_ptr
- week_ptr
- far_ptr
Answer: D) far_ptr
Explanation:
The "far_ptr" is not the correct type of smart pointer in C++.
Discuss this Question
150. Is the "unique_ptr" smart pointer maintaining a reference counter?
- Yes
- No
Answer: B) NO
Explanation:
The "unique_ptr" does not maintain a reference counter while "shared_ptr" maintains a reference counter.
Discuss this Question
151. Which of the following function is used to maintain a reference counter with a smart pointer?
- use_count()
- count()
- ptr_count()
- shared_count()
Answer: A) use_count()
Explanation:
The use_count() function is used to maintain a reference counter with a "shared_ptr" smart pointer.
Discuss this Question
152. Which type of memory is allocated using dynamic memory allocation?
- Stack
- Heap
- Static
- Program code
Answer: B) Heap
Explanation:
When we use dynamic memory allocation, memory is allocated in the heap segment.
Discuss this Question
153. Which of the following is/are used for dynamic memory allocation?
- malloc
- calloc
- new
- free
Options:
- 1 and 2
- 1, 2, and 4
- 2 and 3
- All 1,2,3, and 4
Answer: D) All 1,2,3, and 4
Explanation:
All the given function names and operators are used for dynamic memory allocation in C++.
Discuss this Question
154. Can we allocate memory for an object dynamically?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can allocate memory for an object using "new" and malloc() in C++.
Discuss this Question
155. Is it not required to deallocate the dynamically allocated memory manually in the program?
- Yes
- No
Answer: B) No
Explanation:
We need to manually deallocate the dynamically allocated memory using free() and delete operator in our program.
Discuss this Question
156. Which of the following operator is used to release dynamically allocated memory space?
- new
- remove
- release
- delete
Answer: D) delete
Explanation:
The "delete" operator is used to release dynamically allocated memory space.
Discuss this Question
157. The "new" is a function in C++?
- Yes
- No
Answer: B) No
Explanation:
No, "new" is an operator in C++, which is used to allocate memory space dynamically.
Discuss this Question
158. When we allocate memory space for an object using "new", will it call a constructor?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, when we allocate memory space for an object using the "new" operator, it will call the constructor. But when we allocate memory space for an object using the "malloc ()" function, it will not call the constructor.
Discuss this Question
159. On failure, the "new" operator returns?
- NULL
- -1
- bad_alloc exception
- None of these
Answer: C) bad_alloc exception
Explanation:
On failure, the "new" operator returns a "bad_alloc" exception.
Discuss this Question
160. The "delete" is an operator in C++?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, "delete" is an operator in C++, which is used to deallocate memory space dynamically.
Discuss this Question
161. During the deallocation of dynamically allocated memory for an object using the "free()" function destructor gets called?
- Yes
- No
Answer: B) No
Explanation:
No, the "free()" function does not call the destructor while the "delete" operator call destructor during the deallocation of dynamically allocated memory for an object.
Discuss this Question
162 . Which of the following is a valid way to allocate dynamic memory for an integer variable?
- int *ptr = new int(111);
- int *ptr = NULL;ptr = new int; *ptr=111;
- int *ptr;ptr = new int; *ptr=111;
- All the above
Answer: D) All the above
Explanation:
All the given options are valid to allocate dynamic memory for an integer variable.
Discuss this Question
163. Which of the following is correct?
- "ptr = calloc(a, b)" is equivalent to ptr = malloc(a * b); memset(ptr, 0, a * b);
- "ptr = calloc(a, b)" is equivalent to ptr = malloc(a * b);
- "ptr = calloc(a, b)" is equivalent to ptr = malloc(a); memset(ptr, 0, a);
- "ptr = calloc(a, b)" is equivalent to ptr = malloc(a); memset(ptr, 0, a);
Answer: A) "ptr = calloc(a, b)" is equivalent to ptr = malloc(a * b); memset(ptr, 0, a * b);
Explanation:
Option A is correct.
Discuss this Question
164. What problem may occur with the below code?
#include <stdio.h>
int main()
{
float* ptr = (int*)malloc(sizeof(float));
ptr = NULL;
free(ptr);
}
Options:
- Memory leak
- Dangling pointer
- Compiler error
- None of the above
Answer: A) Memory leak
Explanation:
The above program will create a memory leak because we assigned the NULL to the pointer and free the pointer.
Discuss this Question
165. Which programming language required heap memory allocation in the run time environment?
- A language that uses global variables
- A language that supports dynamic scoping
- A language that allows dynamic data structures
- A language that supports recursion
Answer: C) A language that allows dynamic data structures
Explanation:
A language that allows dynamic data structures required heap memory allocation in the run time environment.
Discuss this Question
166. Which of the following statement is correct about class in C++?
- Class is an instance that contains data member and member functions.
- Class is fundamental that contains data member and member functions.
- Class is a blueprint for a data type that encapsulates data member and member functions.
- None of the above
Answer: C) Class is a blueprint for a data type that encapsulates data member and member functions.
Explanation:
Class is a blueprint for a data type that encapsulates data member and member functions.
Discuss this Question
167. Which of the following symbol is used at the end of the class definition?
- Colon.
- Semicolon.
- Scope Resolution operator.
- None of the above
Answer: B) Semicolon.
Explanation:
The semicolon ( ; ) symbol is used at the end of the class definition.
Discuss this Question
168. Can we define member functions outside the class?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can define member functions inside or outside the class.
Discuss this Question
169. Which of the following symbol is used to define member functions outside the class?
- Colon.
- Semicolon.
- Scope Resolution operator.
- None of the above
Answer: C) Scope Resolution operator.
Explanation:
The scope resolution operator ( :: ) symbol is used to define member functions outside the class.
Discuss this Question
170. By default, members of a class are:
- Public
- Private
- Protected
- None of the above
Answer: B) Private
Explanation:
By default, members of a class are private in C++.
Discuss this Question
171. Can we define a constructor inside the structure?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, just like class, we can define a constructor inside the structure in C++.
Discuss this Question
172. By default, members of a structure are:
- Public
- Private
- Protected
- None of the above
Answer: A) Public
Explanation:
By default, members of a structure are public in C++.
Discuss this Question
173. Can we define a destructor inside the structure?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, just like class, we can define a destructor inside the structure in C++.
Discuss this Question
174. What is the size of an empty class in C++?
- 1 Byte
- 0 Byte
- 2 Byte
- 4 Byte
Answer: A) 1 Byte
Explanation:
The size of an empty class is 1 byte, every object occupies at least one byte to differentiate memory address space for objects.
Discuss this Question
175. Can we create multiple objects of a class in C++?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can create multiple objects of the class in C++.
Discuss this Question
176. Which of the following operator is used to access the members using the object of a class?
- .
- ->
- :
- None of the above
Answer: A) .
Explanation:
The membership operator (.) is used to access the members using the object of a class in C++.
Discuss this Question
177. Which of the following operator is used to access the members using the pointer to the object of a class?
- .
- ->
- :
- None of the above
Answer: B) ->
Explanation:
The referential operator -> is used to access the members using the pointer to the object of a class in C++.
Discuss this Question
178. Is it true, Objects of a class do not share non-static members?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, objects of a class do not share non-static members. Every object has its own copy.
Discuss this Question
179. Can we create a "const" object in C++?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can create a "const" object in C++, using a "const" object. Any attempt to change the data member of const objects results in a compile-time error.
Discuss this Question
180. Can we create "const" member functions in class?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can create "const" member functions in the class. In the "const" member function, we cannot change the value of data members.
Discuss this Question
181. Can we pass a class into a function as an argument in C++?
- Yes
- No
Answer: B) No
Explanation:
No, we cannot pass a class into a function as an argument, we can pass an object of a class as an argument to the function in C++.
Discuss this Question
182. How many types of specifiers can be used in class in C++?
- 1
- 2
- 3
- 4
Answer: C) 3
Explanation:
There are 3 types of specifiers used in class are given below:
- Public
- Private
- Protected
Discuss this Question
183. Which of the following is/are the correct type of class?
- Abstract class
- Concrete class
- Both A and B
- None of the above
Answer: C) Both A and B
Explanation:
Abstract and concrete are the correct types of classes.
Discuss this Question
184. Can we create objects of a class with the definition of class?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can create objects of class at the end of the class definition before the semicolon. For example.
class Sample {
int a, b;
}
obj1, obj2;
Discuss this Question
185. Which of the following statement is correct about constructors in C++?
- A constructor is used to destroy an object.
- Constructor is used to initializing data members when an object gets created.
- Constructor is used to call the private function from outside the class.
- None of the above
Answer: B) Constructor is used to initializing data members when an object gets created.
Explanation:
Constructor is a special type of member function that automatically calls when an object gets created. It is used to initialize the data members of the class.
Discuss this Question
186. How many parameters can be accepted by a default constructor?
- 1
- 2
- 0
- Infinite
Answer: C) 0
Explanation:
A default constructor accepts 0 parameters.
Discuss this Question
187. What is the return type of a constructor?
- void
- int
- float
- None of the above
Answer: D) None of the above
Explanation:
A constructor does not have any return type.
Discuss this Question
188. Which of the following is an incorrect type of constructor in C++?
- Copy constructor
- Move constructor
- Default constructor
- Parameterized constructor
Answer: B) Move constructor
Explanation:
There is no "move constructor" in C++.
Discuss this Question
189. If we did not create any constructor in the class, then which of the following constructor is automatically added to the class?
- Copy constructor
- Default constructor
- Parameterized constructor
- None of the above
Answer: B) Default constructor
Explanation:
If we did not create any constructor in the class, then the default constructor is automatically added to the class.
Discuss this Question
190. Can we overload the constructor in a class?
- Yes
- No
Answer: B) No
Explanation:
Yes, we can create multiple constructors in a class by overloading the constructor.
Discuss this Question
191. A constructor can be inline in C++?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, the constructor can be inline, as we know, inline is a request, not a command.
Discuss this Question
192. A default constructor is also known as a?
- Parameterized constructor
- Copy constructor
- No argument constructor
Answer: C) No argument constructor
Explanation:
A default constructor is also known as a no-argument constructor.
Discuss this Question
193. What will happen, when we create a class with a parameterized constructor and without having a zero-argument constructor, then we create an object of the class that needs a zero argument constructor?
- Linker error
- Compilation error
- Logical error
- None of the above
Answer: B) Compilation error
Explanation:
It will generate a compilation error.
Discuss this Question
194. When we create an object of class using the malloc() function then the constructor gets called?
- True
- False
Answer: B) False
Explanation:
No, when we create an object of class using the malloc() function then the constructor will not call, the constructor gets called when we use the "new" operator for object creation.
Discuss this Question
195. Constructor and Destructor have the same name but destructor is preceded by?
- ~
- !
- $
- #
Answer: A) ~
Explanation:
Constructor and Destructor have the same name but destructor is preceded by a tilde (~) symbol.
Discuss this Question
196. Can we create multiple destructors in class?
- Yes
- No
Answer: B) No
Explanation:
No, we cannot create multiple destructors in a C++ class.
Discuss this Question
197. Can we create a virtual constructor in a class?
- Yes
- No
Answer: B) No
Explanation:
No, we cannot create a virtual constructor in a class. Other than inline, no other keyword is allowed in the declaration of the constructor.
Discuss this Question
198. Can we create a virtual destructor in a class?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can create a virtual destructor in the C++ class.
Discuss this Question
199. Which of the following constructor is used to create an object by initializing data members using an existing object?
- Default constructor
- Dynamic constructor
- Copy constructor
- None of the above
Answer: C) Copy constructor
Explanation:
Copy constructor is used to create an object by initialize data members using existing object.
Discuss this Question
200. Can we implement copy constructor without passing reference of an object into it?
- Yes
- No
Answer: B) No
Explanation:
No, we cannot implement copy constructor without passing a reference of an object into it.
Discuss this Question
201. Which of the following is used to initialize the const members of the class using a constructor?
- Const constructor
- Default constructor
- Member initializer list
- Copy constructor
Answer: C) Member initializer list
Explanation:
In C++, a member initializer list is used to initialize the const members of the class.
Discuss this Question
202. Which of the following is responsible to create a default constructor in the class when the programmer does not create a constructor inside the class?
- Compiler
- Linker
- Loader
- Pre-processor
Answer: C) Loader
Explanation:
In C++, the Compiler is responsible to create a default constructor in the class when the programmer does not create a constructor inside the class.
Discuss this Question
203. When does a destructor gets called?
- When an object gets created
- When an object gets destroyed
- After calling constructor
- None of the above
Answer: B) When an object gets destroyed
Explanation:
A destructor gets called when an object is getting destroyed.
Discuss this Question
204. When we deallocate space for an object of class using the free() function then a destructor gets called?
- True
- False
Answer: B) False
Explanation:
No, when we deallocate space for an object of class using the free () function then a destructor will not call, the destructor gets called when we use the "delete" operator for object destruction.
Discuss this Question
References: C++ | Wikipedia