LogIn
I don't have account.

Practice string Quizzes

Boost your knowledge of string with DevBrainiac's interactive quizzes that make learning faster and more effective. Each quiz focuses on real-world concepts, helping you improve accuracy, understand fundamentals and prepare better for technical interviews. Suitable for beginners and professionals alike, our string quizzes offer a focused, practical approach to mastering the topic.

Explore All string Quizzes

Learn string step by step with interactive quizzes designed for beginners and learners revising key concepts. Build a strong foundation with clear, structured practice in string.
Question 1
Which function is used to concatenate two strings in C?
1
strcmp()
2
strlen()
3
strcat()
4
strcpy()
Question 2
What will be the output of the following C++ code?
Copy
#include <iostream> 
#include <string>
#include <cstring>
using namespace std; 
int main(int argc, char const *argv[])
{
	string a = "Hello\0World";
	cout<<a;
	return 0;
}
1
Hello
2
Hello World
3
Error
4
World
Question 3
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;

int main() 
{
    string str ("Sanfoundry");
    for (size_t i = 0; i < str.length();)
    {
        cout << str.at(i-1);
    }
    return 0;
}
1
Sanfoundry
2
Sanfoundr
3
runtime error
4
anfoundry
Question 4
What will happen if you call ToString() on a null object in C#?
1
It depends on the object's type
2
It returns "null"
3
It throws a NullReferenceException
4
It returns an empty string
Question 5
In JavaScript, which method is used to get the Unicode of a character?
1
charCodeAt()
2
codeAt()
3
asciiCodeAt()
4
getCode()
Question 6
What is the value of '1' + 1 in JavaScript?
1
11
2
NaN
3
TypeError
4
2
Question 7
What will be the output of 'A' + 1 in Python?
1
TypeError
2
66
3
B
4
A1
Question 8
What is the output of the following Java program?
System.out.println('A' + 1);
1
B
2
Compilation Error
3
66
4
A1
Question 9
What will be the output of following Java Code?
public class Test {
    public static void main(String[] args) {
        String a = "hello";
        String b = new String("hello");
        System.out.println(a == b);
    }
}
1
Compilation Error
2
Runtime Error
3
false
4
true
Question 10
What will be the output of following Java Code?
public class Test {
    public static void main(String[] args) {
        String a = "hello";
        String b = "hello";
        System.out.println(a == b);
    }
}
1
true
2
Runtime Error
3
false
4
Compilation Error
Question 11
What will be the output of following Java Code?
public class Test {
    public static void main(String[] args) {
        int x = 5;
        System.out.println(x++ + ++x);
    }
}
1
13
2
10
3
11
4
12
Question 12
What will be the output of following Java Code?
public class Test {
    public static void main(String[] args) {
        String s = "abc";
        s.concat("def");
        System.out.println(s);
    }
}
1
def
2
abc
3
Compilation Error
4
abcdef
Question 13
Can a switch work with strings in C#?
1
no
2
yes
3
Only in .NET Core
4
Only with enums
Question 14
What will be the output of this code?
String str = "Java" + 10 + 20;
System.out.println(str);
1
Java 30
2
Java30
3
Compilation Error
4
Java1020
Question 15
Which method is used to compare two strings ignoring case in Java?
1
compareToIgnoreCase()
2
compareTo()
3
equals()
4
equalsIgnoreCase()
Question 16
What is the output of this code snippet?
String str1 = "Java";
String str2 = "Ja" + "va";
System.out.println(str1 == str2);
1
false
2
true
3
Compilation Error
4
Runtime Error
Question 17
What is the output of the following Python code?
s = "Python"
s[0] = 'p'
print(s)
1
ython
2
Error
3
python
4
Python
Question 18
What will be the output of this code snippet?
text = "abracadabra"
print(text.find('a'), text.rfind('a'))
1
10 0
2
1 10
3
0 0
4
0 10
Question 19
Which method would you use to convert the first character of each word in a string to uppercase and the rest to lowercase?
1
capitalize()
2
title()
3
lower()
4
upper()
Question 20
What is the output of the following code?
s = "Hello\nWorld"
print(r"{}".format(s))
1
Error
2
Hello  
World
3
Hello\nWorld (literally)
4
Hello\nWorld
Question 21
What will be the output of this snippet?
s = "abc" * 3
print(s)
1
abc abc abc
2
Error
3
abcabcabc
4
abc3