MCQ Bank
Which is the correct syntax to define a structure named ‘student’?
- A) struct student{ //variables };
- B) structure student( //variables );
- C) struct student( //variables );
- D) structure student{ //variables };
The ____________ is called automatically when an object destroys
- A) default constructor
- B) constructor
- C) main program
- D) destructor
The function calloc takes two arguments, first argument is the ______________ and the second argument is the ____________.
- A) size of space, number of bytes
- B) size of array , number of bytes
- C) space in terms of string character, size of list
- D) required space in terms of numbers , size of space
Which of the following code segment represents a left shift operator?
- A) result = number << 1 ;
- B) result = number >> 1 ;
- C) cout<<1;
- D) cin >> number ;
Once we have defined a symbolic constant value using #define, that value _________during program execution.
- A) varies
- B) becomes zero
- C) cannot be changed
- D) can be changed
a ^= b; can be written as_________________.
- A) a = b ^ a;
- B) a = a^+b;
- C) a^= a + b;
- D) a = a ^ b;
Which one of the following is used to perform bit-wise exclusive OR operation?
- A) ||
- B) |
- C) ~
- D) ^
__________________function is used to determine the next position to write a character while writing into a file.
- A) seekg()
- B) tellg()
- C) seekp()
- D) tellp()
What is the main difference between a struct and a class in C++?
- A) Classes don’t allow data grouping.
- B) Structs can’t have functions.
- C) There is no difference.
- D) Struct members are public by default; class members are private.
In a class we can have ___________ constructor(s).
- A) two
- B) many
- C) only one
- D) no
What is the storage space of double data type?
- A) 8 bytes
- B) 16 bytes
- C) 64 bytes
- D) 32 bytes
Programmer should be very careful about the memory management because it can _____________.
- A) return void pointers
- B) affect the logic of the program
- C) cause problems of memory leakage and dangling pointers
- D) create problems of NULL pointers
Public member functions of the class ______________main program.
- A) are defined within the
- B) are accessible in
- C) are private to
- D) are not accessible in
What allows an object to interact with private data members of a class?
- A) Public member functions
- B) Inheritance
- C) Global variables
- D) Pointers
We use dot operator to access the data members of both ___________ and ____________.
- A) unions, arrays
- B) arrays, structures
- C) none of them
- D) unions, structures
The data members of the class are initialized ______________.
- A) at compile time
- B) outside the function
- C) at runtime
- D) within main program
Default constructor generated by ______________does ______________for us.
- A) compiler , initialization
- B) compiler, no initialization
- C) classes , initialization
- D) main program, memory management
Which of the following is NOT a valid preprocessor directive?
- A) #define
- B) #function
- C) #ifdef
- D) #pragma
A class is _____________.
- A) a member function
- B) an array
- C) a built in function
- D) a user defined data type
The exclusive OR operator returns 1 if ______________.
- A) None of the given
- B) Both inputs are 1
- C) Both inputs are 0
- D) One input is 1 and other is zero