C++ interview questions part 3

C++ interview questions part 3

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

Total Questions: 20

1. What if we define the below structure in C and C++?

Correct Answer is : Error

2. Which of the following is the scope resolution operator?

Correct Answer is : Segmentation fault

3. What is the output of the following C++ code? #include using namespace std; int x = 1; int main() { int x = 2; { int x = 3; cout << ::x << endl; } return 0; }

Correct Answer is : protected

4. What is the output of the following C++ code? #include using namespace std; class A { ~A(){ cout<<"Destructor called\n"; } }; int main() { A a; return 0; }

Correct Answer is : The variable is visible to its block and to it’s derived class

5. What is the output of the following C++ code? #include using namespace std; class A { ~A(){ cout<<"Destructor called\n"; } }; int main() { A *a1 = new A(); A *a2 = new A(); return 0; }

Correct Answer is : Both Member data & Functions

6. What is the output of the following C++ code? #include using namespace std; int x[100]; int main() { cout << x[99] << endl; }

Correct Answer is : 3010

7. What is the output of the following C++ code? #include using namespace std; int main () { int cin; cin >> cin; cout << "cin: " << cin; return 0; }

Correct Answer is : Allocated

8. Which of the following operator has left to right associativity?

Correct Answer is : Identical results would be produced

9. Which of the following is accessed by a member function of a class?

Correct Answer is : Gates is 56 years old

10. What is the size of a character literal in C and C++?

Correct Answer is : Data accessed

11. What is the size of a character type in C and C++?

Correct Answer is : None of the mentioned

12. Which of the following is correct?

Correct Answer is : It allows the data member to change within a const member function

13. What happens if we run the below code in both C and C++? #include struct STRUCT { int a; int func() { printf("HELLO THIS IS STRUCTURE\n"); } }; int main() { struct STRUCT s; s.func(); return 0; }

Correct Answer is : Both Allocation & Deallocation of memory

14. What happens if we run the below code in both C and C++? #include struct STRUCT { int a = 5; int func() { printf("%d\n", a); } }; int main() { struct STRUCT s; s.func(); return 0; }

Correct Answer is : Standard library

15. What happens if the below code is compiled on both C and C++? #include struct STRUCT { private: int a; }; int main() { printf("%d\n", (int)sizeof(struct STRUCT)); return 0; }

Correct Answer is : 1 4 5 5

16. Which of the following is correct about this pointer in C++?

Correct Answer is : steve jobs

17. Which of the following operator is used with this pointer to access members of a class?

Correct Answer is : HaiHaiHai

18. Why this pointer is used?

Correct Answer is : free

19. How many types of polymorphism are there?

Correct Answer is : memory

20. What is the other name of compile-time polymorphism?

Correct Answer is : Reference to an element

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon