C-Plus-Plus Questions March 21, 2023 | No Comments 0 votes, 0 avg 217 123456789101112131415 C-Plus-Plus Questions 1 / 15 1. What is Pseudo-random number engines? A. Uses user input for random number generation B. Uses an algorithm that does not require any initial seed to generate random numbers C. Uses initial seed based algorithm to generate random numbers D. Random number generates depends on the program 2 / 15 2. What will be the output of the following C++ code? #include using namespace std; class Test { protected: int x; public: Test (int i):x(i) { } void fun() const { cout << "fun() const " << endl; } void fun() { cout << "fun() " << endl; } }; int main() { Test t1 (10); const Test t2 (20); t1.fun(); t2.fun(); return 0; } A. fun() fun() const B. fun() const fun() C. fun() fun() D. fun() const fun() const 3 / 15 3. Observer the given C++ program carefully and choose the correct output from the given options: #include #include using namespace std; int main() { cout<::value; // case A cout<::value; // case B cout<::value; // case c return 0; } A. 11O B. OO1 C. O1O D. none of the above 4 / 15 4. Which of the following C++ code will give error on compilation? ================code 1================= #include using namespace std; int main(int argc, char const *argv[]) { cout<<"Hello World"; return 0; } ======================================== ================code 2================= #include int main(int argc, char const *argv[]) { std::cout<<"Hello World"; return 0; } ======================================== A. Code 1 only B. Neither code 1 nor code 2 C. Both code 1 and code 2 D. Code 2 only 5 / 15 5. What will be the output of the following C++ code? #include #include using namespace std; int main() { cout<::type>::value; cout<::type>::value; return 0; } A. 11 B. 12 C. 21 D. 22 6 / 15 6. What is do-while loop also known as? A. Exit Control B. Entry Control C. Per Tested D. all of the above 7 / 15 7. How structures and classes in C++ differ? A. Structures by default hide every member whereas classes do not B. In Structures, members are public by default whereas, in Classes, they are private by default C. Structures cannot have private members whereas classes can have D. In Structures, members are private by default whereas, in Classes, they are public by default 8 / 15 8. Would destructor be called, if yes, then due to which vector? #include #include using namespace std; class a { public : ~a() { cout << "destroy"; } }; int main() { vector *v1 = new vector; vector *v2 = new vector; return 0; } A. v1 B. v2 C. v1 and v2 D. no destructor call 9 / 15 9. Under which pillar of OOPS does base class and derived class relationship come? A. Polymorphism B. inheritance C. Encapsulation D. Abstraction 10 / 15 10. Consider the following given program and choose the most appropriate output from the given options: #include using namespace std; class Base { public: Base() { cout<<"Constructing Base n"; } ~Base() { cout<<"Destructing Base n"; } }; class Derived: public Base { public: Derived() { cout<<"Constructing Derived n"; } ~Derived() { cout<<"Destructing Derived n"; } }; int main(void) { Derived *d = new Derived(); Base *b = d; delete b; return 0; } A. Constructing Base, Constructing Derived, Destructing Base, Destructing Derived B. Constructing Base, Constructing Derived, Destructing Base C. Constructing Base, Constructing Derived, Destructing Derived, Destructing Base D. none of the above 11 / 15 11. What is C++? A. C++ is an object oriented programming language B. C++ is a procedural programming language C. C++ supports both procedural and object oriented programming language D. C++ is a functional programming language 12 / 15 12. What will be the output of the following C++ code? #include using namespace std; void square (int *x, int *y) { *x = (*x) * --(*y); } int main ( ) { int number = 30; square(&number, &number); cout << number; return 0; } A. 30 B. Error C. Segmentation fault D. 870 13 / 15 13. What will be the output of the following C++ code? #include using namespace std; int gcd (int a, int b) { int temp; while (b != 0) { temp = a % b; a = b; b = temp; } return(a); } int main () { int x = 15, y = 25; cout << gcd(x, y); return(0); } A. 15 B. 25 C. 375 D. 5 14 / 15 14. How can one implement the run-time Polymorphism in the C++ programming language? A. By using the Template B. By using the concepts of inheritance C. By using both the virtual functions and inheritance D. By using only the virtual functions 15 / 15 15. Pick the incorrect statement about Character-Array. A. Character-Array can be terminated by a null character(‘ ’) B. Character-Array has a static size C. Character-Array has a dynamic size D. Character-Array has a threat of array-decay Your score isThe average score is 32% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Questions, Quiz