Ilp C++ Final Quiz

10 Questions | Total Attempts: 40

SettingsSettingsSettings
Please wait...
C Programming Quizzes & Trivia

C++ Final Quiz


Questions and Answers
  • 1. 
    What is the output of the following code class base{    public : virtual void func1()=0;            void func2() {               cout<<"\n In base, function2";  }  }; //end of class class derived : public base{    public :        void fun3()  {               cout<<"\n In derived , function3"; } };//end of class int main(){     derived d;     d.fun3();     return 0;  }
    • A. 

      In derived, function1

    • B. 

      In derived , function3

    • C. 

      Compilation error

    • D. 

      In base, function2

  • 2. 
    A special library function which is called automatically when no handler at any level catches the       exception
    • A. 

      Exit()

    • B. 

      Terminate()

    • C. 

      Quit()

    • D. 

      Ellipse

  • 3. 
    What is the output of the following code      int main() {           char s1[20]="Hello";           char s2[20]="Hai";           s2=s1;           cout<<"String1 : "<<s1;           cout<<"  String2 : "<<s2;           return 0;                                   }
    • A. 

      String1 : Hello String2 : Hai

    • B. 

      String1 : Hello String2 : Hello

    • C. 

      Error : forbidden assignment of arrays

    • D. 

      Error: incompatible types in assignment

  • 4. 
     class Test{  public:          ~Test() {                  cout<<" Destructor"; } };   //end of class  int main() {          Test t;          t.~Test();          return 0;  }
    • A. 

      Run time error

    • B. 

      Destructor Destructor

    • C. 

      Compilation error

    • D. 

      Destructor

  • 5. 
    class VirtualClass {          int x,y;          public:          VirtualClass() {  x=1,y=2; }          virtual void operator<<(ostream&); }; // end of class          void VirtualClass::operator<<(ostream &os)          {  os<<this->x<<"\t"<<this->y;   }         int main() {                     VirtualClass vcObj;                     vcObj<<cout;                     return 0; }
    • A. 

      1 2

    • B. 

      Compilation error

    • C. 

      Run time error

    • D. 

      None of the above

  • 6. 
              int main()           {             int a=2,b=3;             if ((a==2) || (b++==4))             cout<<"success";             return 0;           }           What will be the values of a and b ?
    • A. 

      2,3

    • B. 

      2,4

    • C. 

      2,5

    • D. 

      None of the above

  • 7. 
    What is the output of the below code   int main(){ int i=0; for(i=0;i<20;i++)  switch(i) {     case 0:i+=5;     case 1:i+=2;     case 5:i+=5;     default: i+=4;    }  cout<<i;  return 0;  }
    • A. 

      84

    • B. 

      5

    • C. 

      22

    • D. 

      16

  • 8. 
    What is the output of the following code class base{    public : virtual void display()                        {  cout<<" \n I am in base-display ";}                        void virtual show()             {  cout<<" \n I am in base-show ";             }             virtual void show1(){cout<<"In base show1 ";} }; class derived : public base {}; int main(){  derived d;  cout<<sizeof(d)<<"\n";}
    • A. 

      4

    • B. 

      8

    • C. 

      10

    • D. 

      16

  • 9. 
    What is the output of the following code int main(){    int i=4,j;    j=i<<2;    cout<<j;    return 0;}
    • A. 

      4

    • B. 

      8

    • C. 

      12

    • D. 

      16

  • 10. 
    #define SQR(x) (x*x)    main()    {         int a,b=3;         a=SQR(b+2);         cout<<a;         return 0;     }
    • A. 

      11

    • B. 

      25

    • C. 

      Error

    • D. 

      17