LogIn
I don't have account.
Question 1
Which function is used to concatenate two strings in C?
1
strcmp()
2
strcat()
3
strcpy()
4
strlen()
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
World
2
Hello
3
Hello World
4
Error
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
anfoundry
4
runtime error
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 an empty string
3
It returns "null"
4
It throws a NullReferenceException
Question 5
In JavaScript, which method is used to get the Unicode of a character?
1
codeAt()
2
getCode()
3
charCodeAt()
4
asciiCodeAt()
Question 6
What is the value of '1' + 1 in JavaScript?
1
2
2
NaN
3
11
4
TypeError
Question 7
What will be the output of 'A' + 1 in Python?
1
66
2
TypeError
3
A1
4
B
Question 8
What is the output of the following Java program?
System.out.println('A' + 1);
1
Compilation Error
2
66
3
B
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
false
2
Compilation Error
3
Runtime Error
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
Runtime Error
2
false
3
true
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
12
2
10
3
11
4
13
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
Compilation Error
2
abcdef
3
def
4
abc
Question 13
Can a switch work with strings in C#?
1
yes
2
no
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
Java30
2
Java1020
3
Java 30
4
Compilation Error
Question 15
Which method is used to compare two strings ignoring case in Java?
1
equals()
2
compareToIgnoreCase()
3
compareTo()
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
Compilation Error
2
false
3
Runtime Error
4
true
Question 17
What is the output of the following Python code?
s = "Python"
s[0] = 'p'
print(s)
1
ython
2
python
3
Python
4
Error
Question 18
What will be the output of this code snippet?
text = "abracadabra"
print(text.find('a'), text.rfind('a'))
1
0 0
2
0 10
3
1 10
4
10 0
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
lower()
2
capitalize()
3
upper()
4
title()
Question 20
What is the output of the following code?
s = "Hello\nWorld"
print(r"{}".format(s))
1
Hello  
World
2
Hello\nWorld
3
Hello\nWorld (literally)
4
Error
Question 21
What will be the output of this snippet?
s = "abc" * 3
print(s)
1
abcabcabc
2
abc3
3
abc abc abc
4
Error