Ilp C++ Quiz Prelims 2

16 Questions | Total Attempts: 33

SettingsSettingsSettings
Please wait...
C Programming Quizzes & Trivia

ILP C++ Quiz Prelims 2


Questions and Answers
  • 1. 
    A class which can have only one instance at any time is called as ------------
    • A. 

      Abstract

    • B. 

      Singleton

    • C. 

      Void class

    • D. 

      None of the above

  • 2. 
        int main()     {       char s[]="welcome", *p=s;       cout<<p+p[1]-p[3];       return 0;      }
    • A. 

      Welcome

    • B. 

      Come

    • C. 

      Error

    • D. 

      Lcome

  • 3. 
    The base class of runtime_error is __________
    • A. 

      Runtime class

    • B. 

      Exception_handler class

    • C. 

      Exception class

    • D. 

      Virtual base class

  • 4. 
    Consider the below statement          char *word=”tcs”;          How do you get the address that is stored in the char* variable?
    • A. 

      &word

    • B. 

      Static_cast(word)

    • C. 

      *(&word)

    • D. 

      Static_cast(word)

  • 5. 
    Int main() {   int n1=10,n2=2,k,*p1,*p2;   p1=&n1,p2=&n2;   k=*p1/*p2;   cout<<k;   return 0;  }
    • A. 

      5

    • B. 

      Error

    • C. 

      Division cannot be done over pointers

    • D. 

      10

  • 6. 
    int main() {   int a[20]={1,2,3};   cout<<a++;   return 0;   }
    • A. 

      2

    • B. 

      Address of a

    • C. 

      Compilation error

    • D. 

      Address of a+1

  • 7. 
    Which function helps to extract the string "is left" from the string "23.5 is left"
    • A. 

      Atof()

    • B. 

      Strtod()

    • C. 

      Atod()

    • D. 

      None

  • 8. 
    Which of the header file must be included to use stringstream?
    • A. 

    • B. 

    • C. 

    • D. 

  • 9. 
    If you use same variable for two getline statements
    • A. 

      Both the inputs are stored in that variable

    • B. 

      The second input overwrites the first one

    • C. 

      The second input attempt fails since the variable already got its value

    • D. 

      You can not use same variable for two getline statements

  • 10. 
    The size of following variable is not 4 bytes in 32 bit systems
    • A. 

      Int

    • B. 

      Long int

    • C. 

      Short int

    • D. 

      Float

  • 11. 
    What is the output of the follwing code                 int a=5,*p=&a;                *p++;                  cout<<a<<"\t"<<*p<<endl;                 *++p;                  cout<<a<<"\t"<<*p<<endl;
    • A. 

      5, 5, 6, 6

    • B. 

      5, Garbage Value, 5, Garbage Value

    • C. 

      5, 5, 5, Garbage value

    • D. 

      Garbage Value, 5, 6, Garbage Value

  • 12. 
    class mybase{   }; class myclass : public mybase{ }; myclass m1; int main()   {   mybase *b1 = new myclass();   cout << "object m1 is of type " << typeid(b1).name(); }
    • A. 

      Object m1 is of type myclass

    • B. 

      Object m1 is of type mybase

    • C. 

      Object m1 is of type P6mybase

    • D. 

      Object m1 is of type P6myclass

  • 13. 
    What is the output of the following code snippet ? 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. 

      2 1

    • B. 

      Error

    • C. 

      1 2

    • D. 

      No output

  • 14. 
    Class ConstructTest         {                 public:                 ConstructTest()   {     cout<<"Constructor";     }                 ~ConstructTest()  {    cout<<"Destructor";       }    };         int main()      {                 ConstructTest c[2];                 return 0;         }
    • A. 

      ConstructorDestructorDestructor

    • B. 

      ConstructorConstructorDestructor

    • C. 

      ConstructorConstructorDestructorDestructor

    • D. 

      ConstructorDestructorConstructorDestructor

  • 15. 
    What is the output of the following code snippet ?   class Test { public: Test(int x) { cout<<”Param Construcor”; }  }; //end of class int main() { Test t1=100; return 0;   }
    • A. 

      Compilation Error

    • B. 

      No Ouput

    • C. 

      Param Constructor

    • D. 

      None of the above

  • 16. 
     What is the output of the below code ? class Alpha { public: Alpha(int a=10,int b) {cout<<a<<”\t”<<b;} }; int main() { Alpha x(10,20);}
    • A. 

      Error

    • B. 

      10 20

    • C. 

      No output

    • D. 

      None of the above