C++ interview questions part 43

C++ interview questions part 43

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. What is the output of the following C++ code? #include #include #include   using namespace std;   int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int &q = p; cout<
Correct Answer is : Namespace is used to group class, objects and functions


2. What is the output of the following C++ code? #include #include #include   using namespace std;   int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int *(&q) = p; cout<
Correct Answer is : To structure a program into logical units


3. What is the difference between references and pointers?

Correct Answer is : namespace::operator

4. Pick the correct statement about references in C++.

Correct Answer is : 8

5. What is the output of the following C++ code? #include #include #include   using namespace std;   int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int &q = a; cout<
Correct Answer is : 10


6. What is the output of the following C++ code? #include #include #include   using namespace std;   int main(int argc, char const *argv[]) { int a = 5; int *p = &a; int &q = a; cout<<*p<
Correct Answer is : 16


7. What is the output of the following C++ code? #include #include #include   using namespace std;   int main(int argc, char const *argv[]) { int a = 5; int &q = a; cout<<&a<
Correct Answer is : 55


8. What is the output of the following C++ code? #include #include #include   using namespace std;   int main(int argc, char const *argv[]) { int &q = NULL; cout<
Correct Answer is : 9


9. Pick the correct statement about references.

Correct Answer is : using

10. Which of the following operator is used while declaring references?

Correct Answer is : Namespace has access specifiers like private or public

11. What is the output of the following C++ code? #include #include #include   using namespace std;   void func(const int &a){   int temp = 10; a = temp; cout<
Correct Answer is : ::


12. Which of the following is incorrect?

Correct Answer is : Error

13. Which of the following function must use reference.

Correct Answer is : 5

14. What is the output of the following C++ code? #include using namespace std;   int &fun() { static int x = 10; return x; } int main() { fun() = 30; cout << fun(); return 0; }

Correct Answer is : 20

15. What is the output of the following C++ code? #include using namespace std;   int &fun() { int x = 10; return x; } int main() { fun() = 30; cout << fun(); return 0; }   #include using namespace std;   int &fun() { static int x = 10; return x; } int main() { fun() = 30; cout << fun(); return 0; }

Correct Answer is : 10

16. What is the output of the following C++ code? #include using namespace std;   int main() { int x = 10; int& ref = x; ref = 20; cout << x << endl ; x = 30; cout << ref << endl; return 0; }

Correct Answer is : namespace name{}

17. How a reference is different from a pointer?

Correct Answer is : cout<

18. Which of the following statement(s) is/are correct?

Correct Answer is : 9999999999

19. What kind of error can arise when there is a problem with memory?

Correct Answer is : Declare both the function inside different namespaces

20. What is meant by garbage collection?

Correct Answer is : 25

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon