Question 1
Which function is used to concatenate two strings in C?
1
strcmp()
2
strlen()
3
strcpy()
4
strcat()
Question 2
What will be the output of the following C++ code?
#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
Error
3
World
4
Hello 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
Sanfoundr
2
anfoundry
3
Sanfoundry
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
getCode()
2
asciiCodeAt()
3
codeAt()
4
charCodeAt()
Question 6
What is the value of '1' + 1 in JavaScript?
1
TypeError
2
NaN
3
2
4
11
Question 7
What will be the output of 'A' + 1 in Python?
1
TypeError
2
66
3
A1
4
B
Question 8
What is the output of the following Java program?
System.out.println('A' + 1);
1
66
2
Compilation Error
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
Runtime Error
3
Compilation 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
false
2
Compilation Error
3
Runtime Error
4
true
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
11
2
10
3
12
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
abcdef
2
def
3
abc
4
Compilation Error
Question 13
Can a switch work with strings in C#?
1
no
2
Only in .NET Core
3
Only with enums
4
yes