MCQ Bank
By writing aFile.seekg(15L, ios::cur) we are moving ______________.
- A) 15 bits in the backward direction starting from the previous position
- B) 15 bytes in the backward direction starting from the current position
- C) 15 bits in the backward direction starting from the current position
- D) 15 bytes in the forward direction starting from the current position
Structures are syntactically defined with the word_____________.
- A) struc
- B) struct
- C) structure
- D) None of the given
When is a destructor automatically called?
- A) When an object goes out of scope or is deleted
- B) When an object is created
- C) When a program starts
- D) Only when explicitly called
How is a destructor named in C++?
- A) _ClassName()
- B) ~ClassName()
- C) destroyClassName()
- D) ClassName~()
Shifting the binary numbers is similar to shifting the _____ numbers.
- A) Decimal
- B) Hexadecimal
- C) Base 7
- D) Octal
What is the main advantage of using macros instead of functions for simple tasks?
- A) Macros reduce memory usage
- B) Macros compile faster
- C) Macros avoid function call overhead
- D) Macros are more secure
To access the data members of structure, _______ is used.
- A) Dereference operator
- B) Logical operator
- C) Dot operator
- D) Address operator
The malloc function takes ___________ argument(s).
- A) three
- B) four
- C) two
- D) one
The members of a class declared with the keyword struct are _____________by default.
- A) static
- B) public
- C) protected
- D) private
If we have a program that writes the output data(numbers) to the disc ,and if we collect the output data and write it on the disc in one write operation instead of writing the numbers one by one.
In the above situation the area where we will gather the number is called
- A) Cache
- B) Buffer
- C) Heap
- D) Stack
If we do not write our own assignment operator then which of the following problem may occur?
- A) Unreferenced memory
- B) NULL pointer
- C) Dangling pointer
- D) Memory leak
int &i; It means that i is a _________to an integer.
- A) reference
- B) constant pointer
- C) pointer
- D) data type
Overloaded assignment operator must be
- A) Global function
- B) Non-member function of class
- C) Member function of class
- D) Friend function of class
The friend functions are _____________.
- A) void functions
- B) inline functions
- C) not member of a class
- D) member of a class
When operator function is implemented as member function then return type of function ________.
- A) Must be built-in data type
- B) Must be an object of same class
- C) Can be any data type
- D) Must be user-defined data type
What happens if new fails to allocate memory in C++?
- A) It returns NULL
- B) It returns uninitialized memory
- C) It throws an exception
- D) The program crashes
Let suppose
int a, b, c, d, e;
a = b = c = d = e = 42;
This can be interpreted by the complier as
- A) (a = b = (c = (d = (e = 42))));
- B) a = (b = (c = (d = (e = 42))));
- C) (a = b) = (c = d) = (e = 42);
- D) a = b = (c = (d = (e = 42)));
The friend keyword provides access _______________.
- A) in one direction only
- B) to all classes
- C) in two directions
- D) to the data members of the friend class only
If we use cin stream to read some value and store it in some integer variable and press some alphabet key instead of numeric keys. then what will happen?
- A) Its binary representation will be ignored and the character will be stored
- B) Its binary representation will be ignored and the value will be stored
- C) Its ASCII code will be stored inside the computer
- D) Some error will occur and cin stream will detect this error.
Choose the correct output of the following code in C++. int i =100; int &j = i; j=50; cout<<i++;
- A) 51
- B) 50
- C) 101
- D) 100