C++ Programming Quiz


Play this c++ quiz that will help you to excel in C++ certification exams, placements etc. This C++ programming quiz consist of 10 questions that you need to solve in 10 minutes. We’ve specially designed this quiz so that you can quickly acquaint to the pattern of questions you can be asked in placement drives, certification exams etc. This C++ programming test enables you to assess your knowledge of C++ programming.

Take the Free Practice Test



C++ MCQs

Practice C++ MCQ Questions, which will help you to understand C++ programming related concepts and also helps you to prepare for placements, technical rounds, interviews, competitive exams etc.

C++ Quiz

Try Free C++ Quiz, to start a quiz you need to login first, after login you will get start quiz button and then by clicking on that you can start quiz. You will get 10 Minutes to answer all questions.

C++ Quiz

1. Which of the following statements are true about Catch handler? i) It must be placed immediately after try block T. ii) It can have multiple parameters. iii) There must be only one catch handler for every try block. iv) There can be multiple catch handler for a try block T. v) Generic catch handler can be placed anywhere after try block.

Only i, iv, v
Only i, ii, iii
Only i, iv
Only i, ii

2. Generic pointers can be declared with__________ .

auto
void
asm
None of the above

3. The size of bitset is fixed at compile time that is, it can’t be changed at runtime.

TRUE
FALSE
Can be true and false
Can not say

4. fseek() should be preferred over rewind() mainly because

In rewind, there is no way to check if the operations completed successfully
rewind() doesn't work for empty files
rewind() does work for empty file
All of the above

5. Which of the following statements is correct? i) Change a reference changes the referent. ii) We can create an array of references.

Only 1 is correct.
Only 2 is correct.
Both 1 and 2 are correct.
Both 1 and 2 are incorrect.

6. What is the output of this program?

         
Note:Includes all required header files
 using namespace std;
  class Base
    {
        public:
            Base(){}
            ~Base(){}
            protected:
            private: 
    };
    class Derived:public Base
    {
        public:
            Derived(){}
            Derived(){}
            private:
            protected:
    };
  int main()
  {
     cout << "Executed" << endl;
  } 

Executed
Error
Runtime error
None of the mentioned

7. What will be the output of the following program?

#include <iostream>
using namespace std;
   class course
{
    int x, y; 
    public:
    course(int xx = 0, int yy = 0)
    {
        x = xx; 
        y = yy;
    }
    void Display()
    {
        cout<< x << " " << y;
    }
    course operator +(course z)
    {
        course temp;
        temp.x = x + z.x;
        temp.y = y + z.y;
        return temp; 
    }
};
int main()
{
    course obj(90, 80); 
    course obj2(10, 20); 
    course objSum; 
    course &ref = objSum; 
    ref = obj + obj2; 
    ref.Display(); 
    return 0; 
}

It will result in a runtime error.
It will result in a compile time error.
The program will print the output 9 4.
The program will print the output 100 100.

8. What is the syntax for overriding a virtual function in a derived class?

virtual void functionName() const;
void functionName() override;
virtual void functionName() = 0;
void functionName() const override;

9. What will be the output of this program?

#include <iostream>

using namespace std;

class LFC
{
    private:
        int x,y;
    public:
        void LFC(int a,int b)
        { x=a; y=b;}
};

int main()
{
    LFC s;
    return 0;
}

Compile Time Error
Run Time Error
No Error
Warning

10. What will be the output of this program?

        
Note:Includes all required header files
 using namespace std;
    int main () 
  
{
    FILE *fp;
    char x[1024];
    fp = fopen("find.txt", "r");  // "ayushjain and prateek" 
    x[0] = getc(fp);              
    fseek(fp, 0, SEEK_END);        
    fseek(fp, -7L, SEEK_CUR);      
    fgets(x, 6, fp);             
    puts(x);                     
    return 0;
} 

ayushj
yushja
ayushja
prate

Results