Explore topic-wise MCQs in Technical MCQs.

This section includes 9 Mcqs, each offering curated multiple-choice questions to sharpen your Technical MCQs knowledge and support exam preparation. Choose a topic below to get started.

1.

What does the cerr represent?

A. Standard error stream
B. Standard logging stream
C. Input stream
D. Output stream
E.
Answer» B. Standard logging stream
2.

#include <iostream>using namespace std;class LFC {     public:       int x; }; int main() {     LFC *p = new LFC();     (*p).x = 5;     cout<< (*p).x << " " << p->x << " " ;     p->x = 10;     cout<< (*p).x << " " << p->x ;     return 0; }  
19.Which of the following statements is correct when a class is inherited publicly?

A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Private members of the base class become protected members of derived class.
D. Public members of the base class become public members of derived class.
Answer» E.
3.

        Note:Includes all required header filesusing namespace std;//Empty classclass test{}; int main(){   test testObj;   cout<
18.What will be the output of the following program?

A. 5 5 10 10
B. Garbage garbage 10 10
C. 5 5 Garbage garbage
D. Garbage garbage Garbage garbage
Answer» B. Garbage garbage 10 10
4.

         Note:Includes all required header filesusing namespace std; class sample{    int x;} int main(){    sample obj;    obj.x=100;    cout<
17.What will be the output of this program?

A. Error
B. size =Garbage
C. size =1
D. Compile but no output
Answer» D. Compile but no output
5.

#include <iostream>using namespace std;class LFC { public:     int i;     void get(); }; void LFC::get() {     std::cout << "Enter the value of i: ";     std::cin >> i; } LFC t;  int main() {     LFC t;      t.get();     std::cout << "value of i in local t: "<<t.i<<'\n';     ::t.get();      std::cout << "value of i in global t: "<<::t.i<<'\n';     return 0; }
16.What will be the output of this program?

A. 10
B. 100
C. Error
D. None of the above
Answer» D. None of the above
6.

         Note:Includes all required header filesusing namespace std; class Test{    static int x;    int *ptr;    int y;}; int main(){    Test t;    cout << sizeof(t) << " ";    cout << sizeof(Test *);}
15.Which of the following is true about the following program

A. Compiles and runs fine
B. Compiler Error in Line "::t.get();"
C. Compiler Error: Cannot have two objects with same class name
D. Runtime error
Answer» B. Compiler Error in Line "::t.get();"
7.

       Note:Includes all required header files class Test {  int x; };int main(){  Test t;  cout << t.x;  return 0;}
14.Assume that an integer and a pointer each takes 4 bytes. Also, assume that there is no alignment in objects. Predict the output following program.

A. 12 12
B. 12 4
C. 8 4
D. 8 8
Answer» D. 8 8
8.

         Note:Includes all required header filesusing namespace std; class Empty { }; class Derived: Empty { int a; }; int main(){    cout << sizeof(Derived);    return 0;}
13.What is the output of this program?

A. 0
B. Garbage value
C. Runtime error
D. Complier error
Answer» E.
9.

         Note:Includes all required header filesusing namespace std;  class Empty {};  int main(){  cout << sizeof(Empty);  return 0;}
12.What is the output of this program?

A. 1
B. 2
C. 4
D. Error
Answer» D. Error