Back-End Programming Exam  >  Back-End Programming Tests  >  Learn to Program with C++: Beginner to Expert  >  Test: Strings - 2 - Back-End Programming MCQ

Test: Strings - 2 - Back-End Programming MCQ


Test Description

10 Questions MCQ Test Learn to Program with C++: Beginner to Expert - Test: Strings - 2

Test: Strings - 2 for Back-End Programming 2024 is part of Learn to Program with C++: Beginner to Expert preparation. The Test: Strings - 2 questions and answers have been prepared according to the Back-End Programming exam syllabus.The Test: Strings - 2 MCQs are made for Back-End Programming 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Strings - 2 below.
Solutions of Test: Strings - 2 questions in English are available as part of our Learn to Program with C++: Beginner to Expert for Back-End Programming & Test: Strings - 2 solutions in Hindi for Learn to Program with C++: Beginner to Expert course. Download more important topics, notes, lectures and mock test series for Back-End Programming Exam by signing up for free. Attempt Test: Strings - 2 | 10 questions in 20 minutes | Mock test for Back-End Programming preparation | Free important questions MCQ to study Learn to Program with C++: Beginner to Expert for Back-End Programming Exam | Download free PDF with solutions
Test: Strings - 2 - Question 1

Which of the following function is used to find the first occurrence of a given string in another string?

Detailed Solution for Test: Strings - 2 - Question 1

The function strstr() Finds the first occurrence of a substring in another string
Declaration: char *strstr(const char *s1, const char *s2);
Return Value:
On success, strstr returns a pointer to the element in s1 where s2 begins (points to s2 in s1).
On error (if s2 does not occur in s1), strstr returns null.

Test: Strings - 2 - Question 2

Choose the operator which cannot be overloaded.

Detailed Solution for Test: Strings - 2 - Question 2

Scope resolution (::) is not permitted to be overloaded.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Strings - 2 - Question 3

If the two strings are identical, then strcmp() function returns

Detailed Solution for Test: Strings - 2 - Question 3

Declaration: strcmp(const char *s1, const char*s2);
The strcmp return an int value that is
if s1 < s2 returns a value < 0 if s1 == s2 returns 0 if s1 > s2 returns a value > 0

Test: Strings - 2 - Question 4

In the following program f() is overloaded.

Detailed Solution for Test: Strings - 2 - Question 4

No, as both the functions arguments is same and compiler ignores return type to consider overloading though different in return type.

Test: Strings - 2 - Question 5

What will be the output of the program ?

Detailed Solution for Test: Strings - 2 - Question 5

gets() gets collects a string of characters terminated by a new line from the standard input stream stdin.

The gets(str1) read the input string from user and store in variable str1.

The gets(str2) read the input string from user and store in variable str2.

The code i = strcmp(str1, str2); The strcmp not only returns -1, 0 and +1, but also other negative or positive values. So the value of i is “unpredictable integer value”.

printf(“%d\n”, i); It prints the value of variable i.

Test: Strings - 2 - Question 6

What is the full form of RTTI.

Test: Strings - 2 - Question 7

What will be the output of the program ?

Detailed Solution for Test: Strings - 2 - Question 7

The function printf() returns the number of charecters printed on the console.

char a[] = “\0″; The variable a is declared as an array of characters and it initialized with “\0″. It denotes that the string is empty.

if(printf(“%s”, a)) The printf() statement does not print anything, so it returns ‘0’(zero). Hence the if condition is failed.

In the else part it prints “not empty string”.

Test: Strings - 2 - Question 8

What is the output of the following program?

Detailed Solution for Test: Strings - 2 - Question 8

No output, as we are comparing both base addresses and are not same.

Test: Strings - 2 - Question 9

What will be the output of the program ?

Detailed Solution for Test: Strings - 2 - Question 9

A string is a collection of characters terminated by ‘\0′.

char str[] = “Code\0Quiz\0″; The variable str is declared as an array of characters and initialized with value “Code”

printf(“%s\n”, str); It prints the value of the str.

The output of the program is “Code”.

Test: Strings - 2 - Question 10

Following is the invalid inclusion of a file to the current program. Identify it

Detailed Solution for Test: Strings - 2 - Question 10

option (a) & (b) are valid. There is no such syntax or provision as in option (c).

73 videos|7 docs|23 tests
Information about Test: Strings - 2 Page
In this test you can find the Exam questions for Test: Strings - 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Strings - 2, EduRev gives you an ample number of Online tests for practice
Download as PDF