MCQ Bank
Which of the following is not a file opening mode_________________?
- A) ios::ate
- B) ios::out
- C) ios::in
- D) ios::truncate
What is the use of ios::trunc mode?
- A) To open a file in output mode
- B) To truncate an existing file to half
- C) To truncate an existing file to zero
- D) To open a file in input mode
Constructor has ___________.
- A) the same name as data member
- B) the same name as of class
- C) return type
- D) no name
The original value remains unchanged in _________.
- A) Pointers
- B) Call by value
- C) Dynamic Variables
- D) Call by reference
Structures are syntactically defined with the word_____________.
- A) structure
- B) struc
- C) struct
- D) None of the given
For accessing data members we use _________ operator
- A) multiplication *
- B) plus +
- C) Division /
- D) dot .
The memory allocation functions return a chunk of memory with a pointer of type_______________.
- A) void
- B) ptr
- C) integer
- D) float
The heap memory structure __________.
- A) constantly changes in size
- B) contains no space
- C) remains constant
- D) is just like stack
When accessing a structure member, the identifier to the left of the dot operator is the name of ______________.
- A) Structure member
- B) Structure data
- C) Structure variable
- D) Structure tag
What will be the output of the following c++ code?
#include<iostream.h>
#define max 100
main()
{
#ifdef max
Cout<<”Hellow;
}
- A) Error
- B) Hello
- C) “Hellow”
- D) Max is 100
In shifting operations if zero is inserted at the left most bit, the negative number will become a ______ number.
- A) Greater
- B) Negative
- C) Positive
- D) Smaller
_______________function gives the position of the next character to be read from that file.
- A) tellp()
- B) tellg()
- C) seekg()
- D) seekp()
The_______is the increment Operator in c++.
- A) *+
- B) ++
- C) - -
- D) +*
Which of the following is used to create an output stream?
- A) ofstream
- B) iostream
- C) fsstream
- D) ifstream
A class is _____________.
- A) a built in function
- B) a member function
- C) an array
- D) a user defined data type
Why is casting a void* necessary after memory allocation in C?
- A) Because void pointers are unsafe
- B) Because C requires explicit type specification for void pointers
- C) Because void* cannot be dereferenced directly
- D) Both B and C
What is the correct way to define a macro for squaring a number safely?
- A) #define square(x) ((x) * (x))
- B) #define square(x) x ** 2
- C) #define square(x) x * x
- D) #define square(x) (x) * (x)
The malloc function takes ___________ argument(s).
- A) two
- B) four
- C) one
- D) three
a ^= b; can be written as_________________.
- A) a = b ^ a;
- B) a = a^+b;
- C) a = a ^ b;
- D) a^= a + b;
The data, contained in the structure, is defined in the ______________.
- A) none
- B) curly braces
- C) parenthesis
- D) inverted commas