| 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 is the correct syntax of declaring array of pointers of integers of size 10 in C++?

Correct Answer is : late binding

2. Which of the following is correct about new and malloc? i) new is an operator whereas malloc is a function ii) new calls constructor malloc does not iii) new returns required pointer whereas malloc returns void pointer and needs to be typecast

Correct Answer is : I’m a Human

3. What is the output of the following C++ code? #include using namespace std;   class A { int a; A() { a = 5;} };   int main() { A *obj = new A; cout << obj->a; }

Correct Answer is : Polymorphism

4. What happens if the following statement is compiled and executed in C++? int *ptr = NULL; delete ptr;

Correct Answer is : Error

5. What happens if a pointer is deleted twice in a program as shown by the below statements? int *ptr = new int; delete ptr; delete ptr;

Correct Answer is : Error

6. Pick the other name of operator function.

Correct Answer is : Error

7. Which of the following operators can’t be overloaded?

Correct Answer is : a: 1

8. How to declare operator function?

Correct Answer is : Error

9. Which of the following statements is NOT valid about operator overloading?

Correct Answer is : cin

10. Operator overloading is

Correct Answer is : Error

11. What is the output of the following C++ code? #include #include using namespace std; class A { static int a; public: void show() { a++; cout<<"a: "<
Correct Answer is : None of the mentioned

12. What happens when objects s1 and s2 are added? string s1 = "Hello"; string s2 = "World"; string s3 = (s1+s2).substr(5);

Correct Answer is : It will print what we enter till character t is encountered in the input data

13. What is the output of the following C++ code? #include #include using namespace std; class A { static int a; public: A() { cout<<"Object of A is created\n"; } void show() { a++; cout<<"a: "<
Correct Answer is : 2 or 3

14. What is operator overloading in C++?

Correct Answer is : getline

15. What is the syntax of overloading operator + for class A?

Correct Answer is : After pressing return key

16. How many approaches are used for operator overloading?

Correct Answer is : Unsigned integer of at least 16 bits

17. Which of the following operator cannot be overloaded?

Correct Answer is : x is greater

18. Which of the following operator can be overloaded?

Correct Answer is : (v & (v – 1)) == 0;

19. Which of the following operator cannot be used to overload when that function is declared as friend function?

Correct Answer is : Implementation defined

20. Which of the following operator can be used to overload when that function is declared as friend function?

Correct Answer is : x = x & (x-1)