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 function is invoked.
(C) The definition of the function appears.    
(D) None of the above.
 
  Ans:B
 
Q.78  An exception is caused by

(A)  a runtime error.   
(B)  a syntax error.
(C)  a problem in the operating system.
(D)  a hardware problem.
 
  Ans:A
 
Q.79   Which of the following statements are true in c++?

(A) Classes can not have data as public members.   
(B) Structures can not have functions as members.
(C) Class members are public by default.  
(D) None of these.
 
  Ans:B
 
Q.80   What would be the output of the following program?
   int main()
   {
   int x,y=10,z=10;
    x = (y = =z);
   cout<<x;
   return 0;
   }

(A) 1  (B)  0
(C) 10  (D) Error
 

Ans:A
 
Q.81  What is the error in the following code?
   class t
   {
   virtual void print();
   }

(A)  No error.  
(B)  Function print() should be declared as static.
(C)  Function print() should be defined.  
(D)  Class t should contain data members.
 
  Ans:A
 
Q.82   What will be the output of following program?  

#include<iostream.h>
void main()
{
float x;
x=(float)9/2;
cout<<x;
}  

 
(A)   4.5  (B)  4.0
(C)   4    (D)  5   
 
  Ans:A
 
Q.83   A white space is
:            
   (A)  blank space  (B)  new line
   (C)  tab          (D)  all of the above  
 
  Ans:D
 
Q.84  The following can be declared as friend in a class   
 
(A)  an object  (B)  a class
(C)  a public data member  (D) a private data member
 
  Ans:B
 
Q.85  What would be the output of the following?
   #include<iostream.h>
   void main()
   {
   char *ptr=ΓÇ£abcdΓÇ¥
   char ch;
   ch = ++*ptr++;
   ut<<ch;
   }

 
(A)  a  (B)  b
(C)  c  (D)  d
 
  Ans:B
 
Q.86   A copy constructor takes

(A)  no argument    (B)  one argument
(C)  two arguments  (D)  arbitrary no. of arguments
   
   Ans:B
 
Q87  Overloading a postfix increment operator by means of a member function takes 
 
(A)  no argument    (B)  one argument
(C)  two arguments  (D)  three arguments
 
  Ans:A
 
Q88  Which of the following ways are legal to access a class data member using this pointer?

(A)  this.x    (B)  *this.x
(C)  *(this.x) (D)  (*this).x
 
  Ans:D
 
Q.89  If we store the address of a derived class object into a variable whose type is a pointer to the
base class, then the object, when accessed using this pointer.

(A) continues to act like a derived class object.   
(B) Continues to act like a derived class object if virtual functions are called.
(C) Acts like a base class object.  
(D) Acts like a base class, if virtual functions are called.
 
  Ans:B
 
Q.90  Which of the following declarations are illegal?

(A) void *ptr;  (B)  char *str = ΓÇ£helloΓÇ¥;
(C) char str = ΓÇ£helloΓÇ¥;  (D) const *int p1;
 
  Ans:C

Similar Posts

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

Leave a Reply

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