| Snaprecruit.com

| Snaprecruit.com

Interview question based on skill :

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

Total Questions: 20

1. What does this template function indicates? ================== template void func(T a) { cout<
Correct Answer is : 34567891011

2. What does this template function indicates? ================== template T func(T a) { cout<
Correct Answer is : catch

3. What does this template function indicates? ================== template U func(T a, U b) { cout<
Correct Answer is : throw

4. What is the output of the following C++ code? #include #include #include using namespace std; template T func(T a) { cout< void func(U a) { cout<
Correct Answer is : It will be executed at the end of the program even if the exception arised

5. What is the output of the following C++ code? #include #include #include using namespace std; template T func(T a) { cout<
Correct Answer is : Division by zero condition!

6. What is the output of the following C++ code? #include #include #include using namespace std; template T func(T a) { return a; }   template T func(U a) { return (T)a; }   int main(int argc, char const *argv[]) { int a = 5; int b = func(a); int c = func(5.5); cout<
Correct Answer is : An exception occurred 20

7. Write a template function which takes two numbers, can be integers/real, and an operator as a character ‘+’/’-‘ or as boolean values true/false(representing ‘+’/’-‘ respectively) and returns the results accordingly.

Correct Answer is : My exception

8. What type can be used to replace templates from this function? template T func(T a, T b, U c) { if(c == '+' || c){ return a+b; } else if(c == '-' || !c){ return a-b; } }

Correct Answer is : Depends on the memory

9. What is the syntax of an explicit call for a template? Assume the given template function. template void func(T a, U b) { cout<
Correct Answer is : Exception caught

10. Which of the following is the default return value of functions in C++?

Correct Answer is : inheriting and overriding exception class functionality

11. What is an inline function?

Correct Answer is : bad_cast

12. An inline function is expanded during ______________

Correct Answer is : return

13. In which of the following cases inline functions may not word? i) If the function has static variables. ii) If the function has global and register variables. iii) If the function contains loops iv) If the function is recursive

Correct Answer is : All of the mentioned

14. When we define the default values for a function?

Correct Answer is : Set a global error indicator

15. Where should default parameters appear in a function prototype?

Correct Answer is : c

16. If an argument from the parameter list of a function is defined constant then _______________

Correct Answer is : 0

17. Which of the following feature is used in function overloading and function with default argument?

Correct Answer is : Error

18. What is the output of the following C++ code? #include using namespace std;   int fun(int x = 0, int y = 0, int z) { return (x + y + z); }   int main() { cout << fun(10); return 0; }

Correct Answer is : Improve the exception safety

19. What is 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; }

Correct Answer is : 3

20. What is the output of the following C++ code? #include using namespace std;   int fun(int=0, int = 0);   int main() { cout << fun(5); return 0; } int fun(int x, int y) { return (x+y); }

Correct Answer is : Use the stack