This is a mock Exam for the C++ programmers. It is created by Genesis InSoft Limited
              (admin@genesisinsoft.com)
              and may be freely distributed so long as it is unmodified. Please email us if you
              have any corrections or comments.
           
          
          
            
              What does an empty class contain?
            
              - Default constructor
- Copy constructor 
- Address of operator
- All of the above 
 
          
            Answer to Question 1
          
          
            
              In protected derivation
              
                - Protected and public members of base class become protected 
- Private, protected and public members of base class become protected 
- Private, protected and public members  of base class become private 
- Protected and public members of base class become private
 
          
            Answer to Question 2
          
          
            
              What is the output of the program?
            
            
                  #include <iostream.h>
            
                  void main()
                  {
                      int j = 20, k = 30;
                      int & m = j;
                      int * n = &j;
                      cout << j << " "
              << k << " " << m << " ++ " ;
                      m = k;
                      cout << j << " "
              << k << " " << m << " ++ ";
                      n = &k; // n now points to k
                      cout << j << " "
              << k << " " << m << " " << *n
              << endl;
                  }
            
              - 20 30 20 ++ 20 30 30 ++ 30 30 30 30
- 20 30 20 ++ 30 30 30 ++ 20 30 30 30
- 20 30 20 ++ 20 30 30 ++ 20 30 30 30
- 20 30 20 ++ 30 30 30 ++ 30 30 30 30
 
          
            Answer to Question 3
          
          
            
              Class istream in iostream.h is defined as
              
                - Class istream : public ios 
- Class istream : public virtual ios 
- Class istream : public iostream 
- Class istream : public virtual iostream
 
          
            Answer to Question 4
          
          
            
              Interface contains 
              
                - At least one pure virtual function 
- No pure virtual function 
- All pure virtual functions 
- None of the above
 
          
            Answer to Question 5
          
          
            
              What is the size of empty class?
            
            
              - 0 bytes
- 2 bytes 
- 1 byte
- 4 bytes
 
          
            Answer to Question 6
          
          
            
              The advantage of defining a pure virtual member function in a class is
              
                - Derived class may implement the pure virtual function
- Derived class must implement the pure virtual function
- Derive class is abstract class if it does not implement the pure virtual function
- Both B and C
 
          
            Answer to Question 7
          
          
            
              What is the output of the following?
            
                  #include
                 
              
                  void main()
                  {
              
                      int x, y;
              
                      x=(3, 4, 5);
              
                      y=3, 4, 5;
              
                      cout << endl <<  x <<" 
              "<< y;
              
                  }
              
                - Compilation Error 
- 3 5
- 3 3 
- 5 3 
 
          
            Answer to Question 8
          
          
            
              What is the output of the following?
            
                  #include <iostream.h>
            
                  void main ()
                  {
              
                      {
                          for(int x=1;
              x <= 5; x++, x+=5);
              
                      }
                      cout << endl << " value
              of x = " << x;
              
                  }
              
                - 6 
- 7 
- compilation error 
- 2 
 
          
            Answer to Question 9
          
          
            
              What is the output of the following?
            
                  #include <iostream.h>
            
                  void main ()
                  {
              
                      cout << (cout<<" Hello
              ") << " world ";
              
                  }
              
                - No output is displayed
- Hello some_address_value world 
- Hello world
- compilation error
 
          
            Answer to Question 10
          
          
            
              The class fstreambuf serves as base class for
              
                - ifstream, ofstream, fstream 
- ifstream, ofstream 
- ostream 
- ifstream 
 
          
            Answer to Question 11
          
          
            
              The scope resolution operator permits
              
                - Access to an identifier in the global scope that has been hidden by another identifier
                  with the same name in the local scope
- Access to an identifier in the global space
- Access to an identifier in the local scope
- Access to an identifier in the local scope and global scope
 
          
            Answer to Question 12
          
          
            
              The declaration
              
                  void func_name( )
              
              accepts
              
                - Any no of arguments
- Only one argument
- No Arguments
- None of the above
 
          
            Answer to Question 13
          
          
            
              The technique of allocating memory during runtime on demand is known as
              
                - Dynamic binding 
- Dynamic memory allocation 
- Late binding 
- Template
 
          
            Answer to Question 14
          
          
            
              What is the output of the following?
            
                  #include
            
            
    
    void main()
    { 
        enum col {red, blue, yellow}; 
        col c = blue << 1; 
        cout << c; 
    } <
  - 1 
- 2 
- 3 
- 4 
 
          
            Answer to Question 15
          
          
            
              The advantage of defining a pure virtual member function in a class is
              
                - Derived class may implement the pure virtual function
- Derived class must implement the pure virtual function
- Derive class is abstract class if it does not implement the pure virtual function
- Both B and C
 
          
            Answer to Question 16
          
          
            
              Input and output operators are known as
              
                - extraction and insertion 
- get from and put to 
- Both A and B 
- None of the above
 
          
            Answer to Question 17
          
          
            
              A file can be tied to your program by defining an instance of
              
                - fstream 
- ifstream 
- ofstream 
- All of the above
 
          
          
            Question 19
          
            
              Which of the following is not true about constructor
              
                - constructor can be overloaded
- constructor return type is int
- constructor has the same name as the class in which it is defined
- constructor are used for initializing data members
 
          
            Answer to Question 19
          
            
            
              What is the output of the program?
            
                  #include <iostream.h>
                  char *buf1 = "Genesis", *buf2 = "InSoft";
            
                  void main()
                  {
                      const char *p = buf1;
                      p = buf2;
                      *p = 'g';
                      cout << *p;
                  }
            
              What is the output of the program?
            
              - g
- genesis
- No ouput is displayed
- l-value specifies constant object
 
          
            Answer to Question 20
          
            Answers
          
            Answer 1 - D
          
            Back to question 1
          
            Answer 2 - A
          
            Back to question 2
          
            Answer 3 - D
          
          
            Back to question 3
          
            Answer 4 - B
          
            Back to question 4
          
            Answer 5 - C
          
            Back to question 5
          
            Answer 6 - C
          
            Back to question 6
          
            Answer 7 - D
          
            Back to question 7
          
            Answer 8 - D
          
            Back to question 8
          
            Answer 9 - C
          
            Back to question 9
          
            Answer 10 - B
          
            Back to question 10
          
            Answer 11 - A
          
            Back to question 11
          
            Answer 12 - A
          
            Back to question 12
          
            Answer 13 - C
          
            Back to question 13
          
            Answer 14 - C
          
            Back to question 14
          
            Answer 15 - B
          
            Back to question 15
          
            Answer 16 - D
          
            Back to question 16
          
            Answer 17 - C
          
            Back to question 17
          
            Answer 18 - D
          
            Back to question 18
          
            Answer 19 - B
          
            Back to question 19
          
            Answer 20 - D
          
            Back to question 20