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 -4

    Question 1:   cin extraction stops execution as soon as it finds any blank space character   a.       true b.      false   Question 2:   Observe the following statements and decide what do they do.   string mystring;   getline(cin, mystring);   a.       reads a line of string from cin into mystring b.      reads a…

  • C++ MCQ-12

    Q.1   The address of a variable temp of type float is          (A) *temp  (B) &temp     (C) float& temp  (D) float temp&     Ans: B   Q.2   What is the output of the following code           char symbol[3]={ΓÇÿaΓÇÖ,ΓÇÿbΓÇÖ,ΓÇÿcΓÇÖ};            for (int index=0; index<3; index++)         cout << symbol…

  • 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.   …

  • 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-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 -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…

Leave a Reply

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