C++ interview questions part 55

C++ interview questions part 55

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

Total Questions: 20

1. What is the output of this program? #include #include using namespace std; int main () { string mys; char mya[20]= "Hello world"; mys = mya; cout << mys << '\n'; return 0; }

Correct Answer is : Both pi & i

2. What is the output of this program? #include #include #include using namespace std; bool IsOdd (int i) { return (i % 2) == 1; } int main () { vector myvector; for (int i = 1; i < 10; ++i) myvector.push_back(i); vector :: iterator bound; bound = partition (myvector.begin(), myvector.end(), IsOdd); for (vector :: iterator it = myvector.begin(); it != bound; ++it) cout << ' ' << *it; return 0; }

Correct Answer is : 4base and 7derived

3. When does the next sequence point start?

Correct Answer is : object is NULL

4. What is string objects in C++?

Correct Answer is : Both Class C & A

5. What is Character-Array?

Correct Answer is : Used to hold the type information returned by the typeid operator

6. Pick the incorrect statement about Character-Array.

Correct Answer is : Compile-time construct

7. Pick the correct statement about string objects in C++.

Correct Answer is : Template class sequence container, alternative for C-like arrays

8. What is the output of the following C++ code? #include #include using namespace std; int main(int argc, char const *argv[]) { string str; cin>>str; cout<
Correct Answer is : Sequence Container arrays know (somehow stores within) its size whereas C-like arrays do not


9. What is the output of the following C++ code? #include #include using namespace std; int main(int argc, char const *argv[]) { char str[] = "Hello World"; cout<
Correct Answer is : All of the mentioned


10. What is the output of the following C++ code? #include #include using namespace std; int main(int argc, char const *argv[]) { char str[10]; cin>>str; cout<
Correct Answer is : both at() and get()


11. What is the output of the following C++ code if the string entered by the user is “Hello World”? #include #include using namespace std; int main(int argc, char const *argv[]) { string str; cin>>str; cout<
Correct Answer is : 3


12. Which header file is used to include the string object functions in C++?

Correct Answer is :

13. What is the output of the following C++ code? #include #include using namespace std; int main(int argc, char const *argv[]) { char s1[6] = "Hello"; char s2[6] = "World"; char s3[12] = s1 + " " + s2; cout<
Correct Answer is : array arr;


14. Which of the following is correct way of concatenating two string objects in C++? way 1: string s1 = "hello"; string s2 = "world"; string s3 = s1 + s2;   way 2: string s1 = "hello"; string s2 = "world"; string s3 = s1.append(s2);   way 3: string s1 = "hello"; string s2 = "world"; string s3 = strcat(s1,s2);

Correct Answer is : get<0>(Arr)

15. Which of the following is not a modifier function in string class?

Correct Answer is :

16. Which function is used to get the length of a string object?

Correct Answer is : all of the mentioned

17. What is the identifier given to string class to declare string objects?

Correct Answer is : front()

18. What is the output of the following C++ code? #include #include #include using namespace std; int main(int argc, char const *argv[]) { const char *a = "Hello\0World"; cout<
Correct Answer is : back()


19. What is the output of the following C++ code? #include #include #include using namespace std; int main(int argc, char const *argv[]) { string s("a"); cout<
Correct Answer is : both size() and max_size()


20. Which is the correct way of concatenating a character at the end of a string object? way 1: string s; s = s + 'a';   way 2: string s; s.push_back('a');

Correct Answer is : Swaps two arrays

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon