C++ interview questions part 8

C++ interview questions part 8

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

Total Questions: 20

1. Which type of relationship is modelled by Association?

Correct Answer is : Bit corresponding to an argument is set to 1

2. What is the syntax of class template?

Correct Answer is : Used to make a bit(s) 0 in a bitset

3. What is the output of the following C++ code? #include #include #include using namespace std; template class A { public: A(){ cout<<"Created\n"; } ~A(){ cout<<"Destroyed\n"; } };   int main(int argc, char const *argv[]) { A a; return 0; }

Correct Answer is : All bits are set to 0 in a bitset

4. What is the output of the following C++ code? #include #include #include using namespace std; template class A { public: A(){ cout<<"Created\n"; } ~A(){ cout<<"Destroyed\n"; } };   int main(int argc, char const *argv[]) { A a; return 0; }

Correct Answer is : Bit corresponding to an argument is set to 0

5. What is the output of the following C++ code? #include #include #include using namespace std; template class A { public: A(){ cout<<"Created\n"; } ~A(){ cout<<"Destroyed\n"; } };   int main(int argc, char const *argv[]) { A a1; A a2; A a3; return 0; }

Correct Answer is : Used to flip bit(s) in a bitset

6. What is the output of the following C++ code? #include #include #include using namespace std; template class A { public: T func(T a, T b){ return a/b; } };   int main(int argc, char const *argv[]) { A a1; cout<
Correct Answer is : All bits are flipped in a bitset


7. What is the output of the following C++ code? #include #include #include using namespace std; template class A { public: T func(T a, T b){ return a/b; } };   int main(int argc, char const *argv[]) { A a1; cout<
Correct Answer is : Bit corresponding to argument bit is flipped


8. What is the output of the following C++ code? #include #include #include using namespace std; template class A { public: T func(T a, T b){ return a/b; } };   int main(int argc, char const *argv[]) { A a1; cout<
Correct Answer is : 1110001


9. What is the output of the following C++ code? #include #include #include using namespace std; template class A { T a; public: A(){} ~A(){} };   int main(int argc, char const *argv[]) { A a1; A a2; A a3; cout<
Correct Answer is : 11111000


10. How the template class is different from the normal class?

Correct Answer is : 1011

11. What is the output of the following C++ code? #include #include #include using namespace std; template class A { T a; U b; public: A(T a_val, char b_val = '$'){ this->a = a_val; this->b = b_val; } void print(){ cout< a1(5,10); A a2(5); A a3(10.0); return 0; }

Correct Answer is : ~

12. What is the output of the following C++ code? #include #include #include using namespace std; template class A { T a; U b; public: A(T a_val, char b_val = '$'){ this->a = a_val; this->b = b_val; } void print(){ cout< a1(5,10); A a2(5); A a3(10.0); a1.print(); a2.print(); a3.print(); return 0; }

Correct Answer is : &

13. How many template parameters are allowed in template classes?

Correct Answer is : |

14. How many specifiers are present in access specifiers in class?

Correct Answer is : Yes

15. Which is used to define the member of a class externally?

Correct Answer is : Yes

16. Which other keywords are also used to declare the class other than class?

Correct Answer is : std::vector

17. What is the output of this program? #include using namespace std; class rect { int x, y; public: void val (int, int); int area () { return (x * y); } }; void rect::val (int a, int b) { x = a; y = b; } int main () { rect rect; rect.val (3, 4); cout << "rect area: " << rect.area(); return 0; }

Correct Answer is : std::vector

18. What is the output of this program? #include using namespace std; class CDummy { public: int isitme (CDummy& param); }; int CDummy::isitme (CDummy& param) { if (¶m == this) return true; else return false; } int main () { CDummy a; CDummy *b = &a; if (b->isitme(a)) { cout << "execute"; } else { cout<<"not execute"; } return 0; }

Correct Answer is : FALSE

19. Which of the following is a valid class declaration?

Correct Answer is : FALSE

20. The data members and functions of a class in C++ are by default ____________

Correct Answer is : bool value evaluates to false

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon