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 a virtual member function abc(), then the statement  
      p->abc(); will cause the version of abc() in the __________class to be executed.

(A)  Base Class  (B)  Derived class
(C)  Produces compile time error  (D)  produces runtime error  
 
  Ans:B
 
Q.63   A pure virtual function is a virtual function that   
      
(A)  has no body  (B)  returns nothing
(C)  is used in base class  (D)  both (A) and (C)  

  Ans:D
 
Q.64   A static function

(A) should be called when an object is destroyed.
(B) is closely connected with and individual object of a class.
(C)  can be called using the class name and function name.
(D)  is used when a dummy object must be created.
 
  Ans:C
 
Q.65   We can output text to an object of class ostream using the insertion operator<< because

(A)  the ostream class is a stream  
(B)  the insertion operator works with all classes.
(C)  we are actually outputting to cout.
(D)  the insertion operator is overloaded in ostream.
 
  Ans:D
 
Q.66   The statement f1.write((char*)&obj1, sizeof(obj1));

(A) writes the member function of obj1 to f1.          
(B) Writes the data in obj1 to f1.
(C) Writes the member function and the data of obj1 to f1.          
(D) Writes the address of obj1 to f1.
 
  Ans:B
 
Q.67   To convert from a user defined class to a basic type, you would most likely use.

(A) A built-in conversion function.   
(B) A one-argument constructor.
(C) A conversion function thatΓÇÖs a member of the class.  
(D) An overloaded ΓÇÿ=ΓÇÿ operator.
 
  Ans:C
 
Q.68  Which of the following is not the characteristic of constructor.

(A)  They should be declared in the public section.
(B)  They do not have return type.
(C)  They can not be inherited.
(D)  They can be virtual.
 
  Ans:D
 
Q.69   Name the header file to be included for the use of built in function isalnum()

(A) string.h  (B) process.h
(C) ctype.h  (D) dos.h
 
  Ans:C
 
Q.70   What is the output of given code fragment?

   int f=1, i=2;
   while(++i<5)
   f* =i;
   cout<<f;

(A) 12  (B)  24
(C) 6   (D) 3
 
  Ans:A
 
Q.71  A class defined within another class is:

(A)  Nested class  (B)  Inheritance
(C)  Containership  (D)  Encapsulation
   
  Ans:A
 
Q.72   What will be the values of x, m and n after the execution of the following statements?  
int x, m, n;  
m = 10;  
n = 15;  
x = ++m  +  n++;

(A)  x=25, m=10, n=15  (B)  x=26, m=11, n=16
(C)  x=27, m=11, n=16  (D)  x=27, m=10, n=15  
 
  Ans:B
 
Q.73   Which of the following will produce a value 10 if x = 9.7?    
        
(A)  floor(x)  (B)  abs(x)
(C)  log(x)    (D)  ceil(x)  
 
  Ans:D
 
Q74  The major goal of inheritance in c++ is: 
    
(A) To facilitate the conversion of data types.
(B)  To help modular programming.
(C)  To extend the capabilities of a class.
(D)  To hide the details of base class.
 
  Ans:C
 
Q.75   Consider the following class definitions:
   class a
   {
   };
   class b: protected a  
   {
   };
   What happens when we try to compile this class?

(A) Will not compile because class body of a is not defined.
(B) Will not compile because class body of b is not defined.
(C) Will not compile because class a is not public inherited.
(D) Will compile successfully.
 
  Ans:D

Similar Posts

  • C++ MCQ -7

    Question 1 A variable is/are a.    String that varies during program execution b.    A portion of memory to store a determined value c.    Those numbers that are frequently required in programs d.    None of these   Question 2 Which of the following can not be used as identifiers? a.    Letters b.    Digits c.    Underscores d.   …

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

Leave a Reply

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