Arrays And Strings In C Sharp - Study Mode

[#101] What will be the output of the following C# code? static void Main(string[] args)
{
string s1 = " Cshr "
string s2 = s1.Insert(3 , " a ")
string s3 = s2.Insert(5 , " p ")
for (int i = 0
i < s3.Length
i++)
Console.WriteLine(s3[i])
Console.ReadLine()
}
Correct Answer

(C) Csharp

[#102] What will be the output of the following C# code? static void Main(string[] args)
{
string s1 = "Hello I Love Csharp "
Console.WriteLine(Convert.ToChar( (s1.IndexOf('I') - s1.IndexOf('l')) * s1.IndexOf('p'))
Console.ReadLine()
}
Correct Answer

(D) H

[#103] Which among the following is the correct way to find out the index of second 's' in the string "She sold her beauty in one night to someone else"?
Correct Answer

(C) String a = "She sold her beauty in one night to someone else" int i, j i = a.IndexOf("s") j = a.IndexOf("s", i + 1)

[#104] What will be the output of the following C# code? static void Main(string[] args)
{
string s1 = "Hello"
string s2 = "hello"
if (s1 == s2)
Console.WriteLine("Equal")
else
Console.WriteLine("Unequal")
if (s1.Equals (s2))
Console.WriteLine("Equal")
else
Console.WriteLine("Unequal")
Console.ReadLine()
}
Correct Answer

(D) Unequal Unequal

[#105] What will be the output of the following C# code snippet? static void main(String args[])
{
char chars[] = {'x', 'y', 'z'}
String s = new String(chars)
Console.WriteLine(s)
}
Correct Answer

(D) xyz