C++ MCQ-10

Q.16   If we create a file by ΓÇÿifstreamΓÇÖ, then the default mode of the file is _________   
(A)  ios :: out  (B)  ios :: in
(C)  ios :: app  (D)  ios :: binary
 
  Ans: B
 
Q.17   A variable defined within a block is visible  
 
   (A) from the point of definition onward in the program.    
   (B) from the point of definition onward in the function.
   (C) from the point of definition onward in the block.   
   (D) throughout the function.
 
   Ans: C   
 
Q.18   The break statement causes an exit   
                 
        (A) from the innermost loop only.  (B) only from the innermost switch.
        (C) from all loops & switches.  (D) from the innermost loop or switch.
   
  Ans: D
 
Q.19   Which of the following cannot be legitimately passed to a function

 (A)  A constant.  (B) A variable.
 (C)  A structure.  (D) A header file.  
 
   Ans: D
 
Q.20  A property which is not true for classes is that they 
                                 
(A)   are removed from memory when not in use.   
(B)   permit data to be hidden from other classes.
(C)   bring together all aspects of an entity in one place.  
(D)   Can closely model objects in the real world.
     
   Ans: C
 
Q.21  You can read input that consists of multiple lines of text using
 
(A)   the normal cout << combination.  
(B)   the cin.get( ) function with one argument.
(C)   the cin.get( ) function with two arguments.  
(D)   the cin.get( ) function with three arguments.
 
   Ans: C
 
Q.22   The keyword friend does not appear in 
 
(A)   the class allowing access to another class.   
(B)   the class desiring access to another class.
(C)   the private section of a class.  
(D)   the public section of a class.
 
   Ans: C
 
Q.23   The process of building new classes from existing one is called

(A)  Structure.  (B)  Inheritance.
(C)  Polymorphism.  (D)  Template.
 
   Ans: B
 
Q.24  If you wanted to sort many large objects or structures, it would be most efficient to
 
    
(A)    place them in an array & sort the array.   
(B)    place pointers to them in an array & sort the array.
(C)    place them in a linked list and sort the linked list.  
(D)    place references to them in an array and sort the array.
   
   Ans: C
 
Q.25   Which statement gets affected when i++ is changed to ++i?
   
   (A) i = 20; i++;    
   (B) for (i = 0; i<20; i++) { }
   (C) a = i++;  
   (D) while (i++ = 20) cout <<i;
 
   Ans: A
 
Q.26   A friend function to a class, C cannot access 
                   
    (A) private data members and member functions.
    (B) public data members and member functions.
    (C) protected data members and member functions.  
    (D) the data members of the derived class of C.
   
  Ans: D
 
Q.27  The operator that cannot be overloaded is  
 
(A)  ++  (B) ::
(C)  ( )  (D) ~  
 
   Ans: B   
 
Q.28   A struct is the same as a class except that
                                  
(A)   there are no member functions.   
(B)   all members are public.
(C)   cannot be used in inheritance hierarchy.  
(D)   it does have a this pointer.
     
  Ans: C
 
Q.29  Pure virtual functions
 
(A) have to be redefined in the inherited class.   
(B) cannot have public access specification.
(C) are mandatory for a virtual class.  
(D) None of the above.
 
   Ans: A
 
Q.30  Additional information sent when an exception is thrown may be placed in  

(A)  the throw keyword.   
(B)  the function that caused the error.
(C)  the catch block.  
(D)  an object of the exception class.
 
   Ans: C

Similar Posts

  • C++ MCQ-15

    Q.76   Which of the following expressions is illegal? (A)  ( ) 6 10 .  (B)  (false && true) (C)  bool (x) = (bool)10;  (D)  float y = 12.67;       Ans:C   Q.77  The actual source code for implementing a template function is created when   (A) The declaration of function appears. (B) The…

  • C++ MCQ -5

    Question 1 Streams are a.       Abstraction to perform input and output operations in sequential media b.      Abstraction to perform input and output operations in direct access media c.       Objects  where a program can either insert or extract characters to and from it d.      Both a and c   Question 2 Which of the following is…

  • C++ MCQ -3

    Question 1: Find out the error in following block of code. If (x = 100)     Cout << ΓÇ£x is 100ΓÇ¥; a.       100 should be enclosed in quotations b.      There is no semicolon at the end of first line c.       Equals to operator mistake d.      Variable x should not be inside quotation   Question 2:…

  • C++ MCQ-16

    Q.91   What will be the result of the expression 13 & 25? (A) 38  (B)  25 (C)  9  (D)  12      Ans:C  Q.92   Which of the following operator can be overloaded through friend function? (A)  ->   (B)  = (C)  ( )   (D)  *        Ans:D   Q.93  To access the public function…

  • C++ MCQ-14

    Q.61  An array element is accessed using (A)  a FIFO approach  (B)  an index number (C)  the operator  (D)  a member name     Ans:B   Q.62   If there is a pointer p to object of a base class and it contains the address of an object of a derived class and both classes contain…

Leave a Reply

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