CPP questions for practice

Embed Size (px)

DESCRIPTION

A good collection of questions on C++ conforming with the latest standard

Citation preview

C++ Test Paper (APT Software Avenues Pvt. Ltd.)1. What is the output of this program?1. #include 2. using namespace std;3. class Base4. {5. public:6. virtual void print() const = 0;7. };8. class DerivedOne : virtual public Base9. {10. public:11. void print() const12. {13. cout set_values (4, 5);37. ppoly2->set_values (4, 5);38. cout area() ;39. cout area();40. return 0;41. }a) 1020b) 20c) 10d) 20104. Which operator is used to signify the namespace?a) conditional operatorb) ternary operatorc) scope operatord) none of the mentioned

5. Identify the correct statement.a) Namespace is used to group class, objects and functions.b) Namespace is used to mark the beginning of the program.c) Namespace is used to seperate the class, objects.d) None of the above

6. What is the output of these program?1. #include 2. using namespace std;3. namespace first4. {5. int x = 5;6. int y = 10;7. }8. namespace second9. {10. double x = 3.1416;11. double y = 2.7183;12. }13. int main ()14. {15. using first::x;16. using second::y;17. bool a, b;18. a = x > y;19. b = first::y < second::x;20. cout