C++ interview questions part 53

C++ interview questions part 53

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

Total Questions: 20

1. Which function can be used to find the sum of a vector container?

Correct Answer is : In swap 105 In main 105

2. Which header file is required to use accumulate() function?

Correct Answer is : Alternate name for the variable

3. What is any in C++?

Correct Answer is : 10

4. In how many different ways any-container can be constructed?

Correct Answer is : Hello world

5. What is the correct syntax of constructing any using copy initialization?

Correct Answer is : we can not create the array of reference

6. What is the correct syntax of constructing any using parameterized constructor?

Correct Answer is : An alternative name for already existing variables

7. What is the correct syntax of constructing any using assignment operator?

Correct Answer is : Compile-time error

8. Which of the following syntax is used to convert any variable to its original type?

Correct Answer is : Error

9. Which header file is required to use any container?

Correct Answer is : 5

10. What is the output of the following C++ code? #include #include using namespace std; int main() { int a = 5; any var = a; cout<
Correct Answer is : Compile-time error


11. What is the output of the following C++ code? #include #include #include using namespace std; int main() { string s = "Hello World"; any var(s); cout<(var)<
Correct Answer is : Address of pointer a


12. What is the output of the following C++ code? #include #include #include using namespace std; int main() { string s = "Hello World"; any var(s); cout<(var)<
Correct Answer is : References are an alias for a variable whereas pointer stores the address of a variable


13. Which exception is thrown if the typecasting is not done properly?

Correct Answer is : References and variables both have the same address

14. What is the use of emplace() function?

Correct Answer is : Address of a followed by 5 in next line

15. What is the output of the following C++ code? #include #include using namespace std; int main() { float val = 5.5; any var(val); cout<(c); cout<
Correct Answer is : Compile time error


16. What is the output of the following C++ code? #include #include using namespace std; int main() { float val = 5.5; any var(val); cout<
Correct Answer is : Error


17. What is the use of has_value() function in any container?

Correct Answer is : References once assigned cannot be changed to refer another variable

18. What is the output of the following C++ code? #include #include using namespace std; int main() { float val = 5.5; any var(val); if(var.has_value()) { cout<<"Var is not Empty\n"; } else { cout<<"Var is Empty\n"; } return 0; }

Correct Answer is : &

19. What is the use of reset() function?

Correct Answer is : Error

20. What is the output of the following C++ code? #include #include using namespace std; int main() { float val = 5.5; any var(val); cout<(var)<
Correct Answer is : 343


Similar Interview Questions

    Search for latest jobs

    Icon
    Icon