Ilp C++ Quiz Prelims 2

16 Questions | Attempts: 39
Share
SettingsSettings
Please wait...
  • 1/16 Questions

    A class which can have only one instance at any time is called as ------------

    • Abstract
    • Singleton
    • Void class
    • None of the above
Please wait...
About This Quiz

ILP C++ Quiz Prelims 2

C Programming Quizzes & Trivia

Quiz Preview

  • 2. 

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

    • 2

    • Address of a

    • Compilation error

    • Address of a+1

    Correct Answer
    A. Compilation error
  • 3. 

    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;

    • 5, 5, 6, 6

    • 5, Garbage Value, 5, Garbage Value

    • 5, 5, 5, Garbage value

    • Garbage Value, 5, 6, Garbage Value

    Correct Answer
    A. 5, Garbage Value, 5, Garbage Value
  • 4. 

    If you use same variable for two getline statements

    • Both the inputs are stored in that variable

    • The second input overwrites the first one

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

    • You can not use same variable for two getline statements

    Correct Answer
    A. The second input overwrites the first one
  • 5. 

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

    • ConstructorDestructorDestructor

    • ConstructorConstructorDestructor

    • ConstructorConstructorDestructorDestructor

    • ConstructorDestructorConstructorDestructor

    Correct Answer
    A. ConstructorConstructorDestructorDestructor
  • 6. 

    The base class of runtime_error is __________

    • Runtime class

    • Exception_handler class

    • Exception class

    • Virtual base class

    Correct Answer
    A. Exception class
  • 7. 

    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;    }

    • 2 1

    • Error

    • 1 2

    • No output

    Correct Answer
    A. 1 2
  • 8. 

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

    • Welcome

    • Come

    • Error

    • Lcome

    Correct Answer
    A. Lcome
  • 9. 

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

    • 5

    • Error

    • Division cannot be done over pointers

    • 10

    Correct Answer
    A. Error
  • 10. 

    Which function helps to extract the string "is left" from the string "23.5 is left"

    • Atof()

    • Strtod()

    • Atod()

    • None

    Correct Answer
    A. Strtod()
  • 11. 

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

    • Object m1 is of type myclass

    • Object m1 is of type mybase

    • Object m1 is of type P6mybase

    • Object m1 is of type P6myclass

    Correct Answer
    A. Object m1 is of type P6mybase
  • 12. 

    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;   }

    • Compilation Error

    • No Ouput

    • Param Constructor

    • None of the above

    Correct Answer
    A. Param Constructor
  • 13. 

     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);}

    • Error

    • 10 20

    • No output

    • None of the above

    Correct Answer
    A. Error
  • 14. 

    The size of following variable is not 4 bytes in 32 bit systems

    • Int

    • Long int

    • Short int

    • Float

    Correct Answer
    A. Short int
  • 15. 

    Which of the header file must be included to use stringstream?

    Correct Answer
    A.
  • 16. 

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

    • &word

    • Static_cast(word)

    • *(&word)

    • Static_cast(word)

    Correct Answer
    A. Static_cast(word)

Quiz Review Timeline (Updated): Mar 20, 2022 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 20, 2022
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 12, 2012
    Quiz Created by
    Srikanth_kanthet
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.