MCQ Bank
________________ for parameters is also done for inline functions.
- A) Value checking
- B) Automatic type checking
- C) Syntax checking
- D) Testing
What type of memory is used when you allocate memory dynamically in C?
- A) Code Segment
- B) Data Segment
- C) Heap
- D) Stack
In a class we can have ___________ constructor(s).
- A) no
- B) two
- C) only one
- D) many
Which of the following memory allocation types occurs at compile-time?
- A) Runtime Allocation
- B) Static Memory Allocation
- C) Heap Allocation
- D) Dynamic Memory Allocation
Array indexes start from __________.
- A) 2
- B) 1
- C) 0
- D) 3
We use dot operator to access the data members of both ___________ and ____________.
- A) none of them
- B) arrays, structures
- C) unions, structures
- D) unions, arrays
Sometimes after allocating memory we need additional space, for this purpose we use ______________.
- A) realloc function
- B) reallocation function
- C) calloc function
- D) void pointer
Default constructor takes _________.
- A) one parameter
- B) two parameters
- C) character type parameter
- D) no parameters
What is the main difference between a struct and a class in C++?
- A) Struct members are public by default; class members are private.
- B) Structs can’t have functions.
- C) There is no difference.
- D) Classes don’t allow data grouping.
Constructor is itself a __________ of C++ and ___________.
- A) object, can not be initialized
- B) class , can be overloaded
- C) function , cannot be overloaded
- D) function, can be overloaded
What can the resultant number when you AND two numbers 12 & 8 bit-wise using & operator?
- A) 8
- B) 6
- C) 12
- D) 4
How is a destructor named in C++?
- A) _ClassName()
- B) ClassName~()
- C) destroyClassName()
- D) ~ClassName()
For converting a void type pointer ptr into integer type, the correct syntax is:
- A) *int ptr
- B) (int *) ptr
- C) int * ptr
- D) ptr * int
Why is it a good practice to write macro names in capital letters?
- A) It avoids runtime errors
- B) It is required by the compiler
- C) It helps distinguish macros from functions and variables
- D) It speeds up macro execution
Look at the program code and identify the error. #include<iostream> using namespace std; #define PI 3.1415926; main() { int radius = 5; cout << "Area of circle with radius " << radius << " = " << PI * radius * radius; }
- A) It will be compiled and returns nothing
- B) Error exists in line number 2. Semi colon is not allowed with define directive
- C) It will be compiled successfully and will not generate error
- D) The value of PI cannot be defined in the beginning
A file opened with the help of ______________ can be used for both input and output.
- A) iostream
- B) fstream
- C) ifstream
- D) ofstream
Which header file is required to use file I/O operations?
- A) <ostream>
- B) <fstream>
- C) <iostream>
- D) <ifstream>
What does the calloc function return if it fails to allocate memory?
- A) 0
- B) -1
- C) NULL
- D) It crashes the program
Which is the correct syntax to define a structure named ‘student’?
- A) struct student{ //variables };
- B) struct student( //variables );
- C) structure student( //variables );
- D) structure student{ //variables };
A file opened with ________________ is used for input and cannot be used for output.
- A) ifstream
- B) conio
- C) ofstream
- D) iostream