C# Programming :: Strings - C#
-
Which of the following statements are true about the C#.NET code snippet given below?
String s1, s2; s1 = "Hi"; s2 = "Hi";
- String objects cannot be created without using new.
- Only one object will get created.
- s1 and s2 both will refer to the same object.
- Two objects will get created, one pointed to by s1 and another pointed to by s2.
- s1 and s2 are references to the same object.
-
Which of the following will be the correct output for the C#.NET code snippet given below?
String s1 = "ALL MEN ARE CREATED EQUAL"; String s2; s2 = s1.Substring(12, 3); Console.WriteLine(s2);
-
Which of the following statements will correctly copy the contents of one string into another ?
-
The string built using the String class are immutable (unchangeable), whereas, the ones built- using the StringBuilder class are mutable.
-
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);
-
If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references?
-
Which of the following snippets are the correct way to convert a Single into a String?
Single f = 9.8f; String s; s = (String) (f);
Single f = 9.8f; String s; s = Convert.ToString(f);
Single f = 9.8f; String s; s = f.ToString();
Single f = 9.8f; String s; s = Clnt(f);
Single f = 9.8f; String s; s = CString(f);
-
Which of the following will be the correct output for the C#.NET code snippet given below?
String s1="Kicit"; Console.Write(s1.IndexOf('c') + " "); Console.Write(s1.Length);
-
Which of the following is correct way to convert a String to an int?
String s = "123"; int i; i = (int)s;
String s = "123"; int i; i = int.Parse(s);
String s = "123"; int i; i = Int32.Parse(s);
String s = "123"; int i; i = Convert.ToInt32(s);
String s = "123"; int i; i = CInt(s);
-
Which of the following statements about a String is correct?