C++ MCQ-13

Q.46   Given a class named Book, which of the following is not a valid constructor?  
(A)  Book ( ) { }               (B)  Book ( Book b) { }
(C)  Book ( Book &b) { }   (D)  Book (char* author, char* title) { }
   
  Ans:B
 
Q47  Which of the statements is true in a protected derivation of a derived class from a base class?

(A)  Private members of the base class become protected members of the derived class  
(B) Protected members of the base class become public members of the derived class
(C) Public members of the base class become protected members of the derived class  
(D) Protected derivation does not affect private and protected members of the derived class.
 
  Ans:C
 
Q48  Which of the following statements is NOT valid about operator overloading?  

(A)  Only existing operators can be overloaded.   
(B)  Overloaded operator must have at least one operand of its class type.
(C)  The overloaded operators follow the syntax rules of the original operator.
(D)  none of the above.  
 
   Ans:D
 
Q.49  Exception handling is targeted at  

(A) Run-time error  (B) Compile time error
(C) Logical error  (D) All of the above.
   
  Ans:A
 
Q.50   A pointer to the base class can hold address of
 
(A) only base class object   
(B) only derived class object
(C) base class object as well as derived class object  
(D) None of the above

 Ans:C
 
Q.51   Function templates can accept

(A)  any type of parameters   
(B)  only one parameter
(C)  only parameters of the basic type
(D)  only parameters of the derived type
 
  Ans:C
 
Q.52   How many constructors can a class have?

(A)  0  (B)  1
(C)  2  (D)  any number  
 
  Ans:D
 
Q.53   The new operator 
          
(A)   returns a pointer to the variable  
(B)   creates a variable called new
(C)  obtains memory for a new variable   
(D)  tells how much memory is available
   
  Ans:C
 
Q.54  Consider the following statements:

   int x = 22,y=15;
   x = (x>y) ? (x+y) : (x-y);  
   What will be the value of x after executing these statements?

(A)   22  (B)  37
(C)   7   (D)  Error. Cannot be executed
   
  Ans:B
 
Q.55  An exception is caused by

(A)  a hardware problem  (B) a problem in the operating system
(C)  a syntax error      (D)  a run-time error
 
  Ans:D  
 
Q.56  A template class

(A)  is designed to be stored in different containers           
(B) works with different data types
(C)  generates objects which must be identical          
(D)  generates classes with different numbers of member functions.
 
   Ans:B

Q.57  Which of the following is the valid class declaration header for the derived class d with base
classes b1 and b2?
(A)  class d : public b1, public b2 (B)  class d : class b1, class b2
(C)  class d : public b1, b2  (D)  class d : b1, b2
 
   Ans:A
 
Q.58  A library function exit() causes an exit from  

(A)  the loop in which it occurs  (B)  the block in which it occurs
(C)  the function in which it occurs  (D)  the program in which it occurs  
 
  Ans:D
 
Q.59  RunTime polymorphism is achieved by ___________

(A) friend function  (B) virtual function
(C) operator overloading  (D) function overloading
 
  Ans:B
 
Q.60 Declaration of a pointer reserves memory space
 
(A)  for the object.
(B)  for the pointer.
(C)  both for the object and the pointer.
(D)  none of these.
 

   Ans:B

Similar Posts

  • C++ MCQ-11

    Q.31  Use of virtual functions implies (A)  overloading.  (B)  overriding. (C)  static binding.  (D)  dynamic binding. Ans: D   Q.32   this pointer      (A)  implicitly points to an object.    (B)  can be explicitly used in a class. (C)  can be used to return an object.   (D)  All of the above.    Ans: D…

  • C++ MCQ -6

    Question 1 In an assignment statement a=b; Which of the following statement is true? a.    The variable a and the variable b are equal. b.    The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable a c.    The value of b is…

  • C++ MCQ -1

    Question 1. What is the correct value to return to the operating system upon the successful completion of a program? A. -1 B. 1 C. 0 D. Programs do not return a value.   Question 2. What is the only function all C++ programs must contain? A. start() B. system() C. main() D. program()  …

  • C++ MCQ -2

    Question 1: The void specifier is used if a function does not have return type. a.       True b.      False   Question 2: You must specify void in parameters if a function does not have any arguments. a.       True b.      False   Question 3: Type specifier is optional when declaring a function a.       True b.      False…

  • C++ MCQ -9

    Question 1: A function can not be overloaded only by its return type. a. True b. False   Question 2: A function can be overloaded with a different return type if it has all the parameters same. a. True b. False   Question 3: Inline functions involves some additional overhead in running time. a. True…

  • C++ MCQ -8

    Question 1 Identify the correct statement a. Programmer can use comments to include short explanations within the source code itself. b. All lines beginning with two slash signs are considered comments. c. Comments very important effect on the behaviour of the program d. both   Question 2 The directives for the preprocessors begin with a.   …

Leave a Reply

Your email address will not be published. Required fields are marked *