Exercise: Strings

Questions for: Strings

What will be the output of the C#.NET code snippet given below?
namespace ExamAdept
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            string str= "Hello World!";
            Console.WriteLine( String.Compare(str, "Hello World?" ).GetType() );
        }
    }
}
A:
0
B:
1
C:
String
D:
Hello World?
Answer: E
No answer description is available. Let's discuss.
If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references?
A:
s1 is s2
B:
s1 = s2
C:
s1 == s2
D:
strcmp(s1, s2)
Answer: E
No answer description is available. Let's discuss.
Which of the following will be the correct output for the C#.NET code snippet given below?
String s1 = "Nagpur";
String s2;
s2 = s1.Insert(6, "Mumbai"); 
Console.WriteLine(s2);
A:
NagpuMumbair
B:
Nagpur Mumbai
C:
Mumbai
D:
Nagpur
Answer: E
No answer description is available. Let's discuss.
The string built using the String class are immutable (unchangeable), whereas, the ones built- using the StringBuilder class are mutable.
A:
True
B:
False
C:
D:
Answer: A
No answer description is available. Let's discuss.
Which of the following statements will correctly copy the contents of one string into another ?
A:
String s1 = "String";
String s2; 
s2 = s1;
B:
String s1 = "String" ; 
String s2;
s2 = String.Concat(s1, s2);
C:
String s1 = "String"; 
String s2;
s2 = String.Copy(s1);
D:
String s1 = "String"; 
String s2;
s2 = s1.Replace();
Answer: C
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz