adplus-dvertising

Welcome to the Arrays and Strings MCQs Page

Dive deep into the fascinating world of Arrays and Strings with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Arrays and Strings, a crucial aspect of C# Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Arrays and Strings, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C# Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Arrays and Strings. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C# Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Arrays and Strings. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Arrays and Strings MCQs | Page 3 of 16

Explore more Topics under C# Programming

Q21.
If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references?
Discuss
Answer: (d).s1.Equals(s2)
Q22.
What will be the output of the C#.NET code snippet given below?

namespace CompSciBitsConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            string str= "Hello World!";
            Console.WriteLine( String.Compare(str, "Hello World?" ).GetType() );
        }
    }
}
Discuss
Answer: (d).System.Int32
Q23.
Which of the following snippets are the correct way to convert a Single into a String?
1.
Single f = 9.8f; 
String s;
s = (String) (f);

2.
Single f = 9.8f; 
String s;
s = Convert.ToString(f);

3.
Single f = 9.8f; 
String s;
s = f.ToString();

4.
Single f = 9.8f; 
String s;
s = Clnt(f);

5.
Single f = 9.8f; 
String s;
s = CString(f);
Discuss
Answer: (b).2, 3
Q24.
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);
Discuss
Answer: (b).2 5
Q25.
Which of the following is correct way to convert a String to an int?
1.
String s = "123"; 
int i;
i = (int)s;

2.
String s = "123";
int i;
i = int.Parse(s);

3.
String s = "123"; 
int i;
i = Int32.Parse(s);

4.
String s = "123"; 
int i;
i = Convert.ToInt32(s);

5.
String s = "123"; 
int i;
i = CInt(s);
Discuss
Answer: (d).2, 3, 4
Discuss
Answer: (b).A String is created on the heap.
Discuss
Answer: (d).A String has a zero-based index.
Q28.
Which of the following will be the correct output for the C#.NET code snippet given below?

String s1 = "Five Star";
String s2 = "FIVE STAR";
int c;
c = s1.CompareTo(s2);
Console.WriteLine(c);

a.

0

b.

1

c.

2

d.

-1

Discuss
Answer: (d).-1
Q29.
If s1 and s2 are references to two strings then which of the following are the correct ways to find whether the contents of the two strings are equal?

1. if(s1 = s2)
2. if(s1 == s2)
3. int c;
c = s1.CompareTo(s2);
4. if( strcmp(s1, s2) )
5. if (s1 is s2)
Discuss
Answer: (b).2, 3
Q30.
Which of the following statements are correct about the String Class in C#.NET?

1. Two strings can be concatenated by using an expression of the form s3 = s1 + s2;
2. String is a primitive in C#.NET.
3. A string built using StringBuilder Class is Mutable.
4. A string built using String Class is Immutable.
5. Two strings can be concatenated by using an expression of the form s3 = s1&s2;
Discuss
Answer: (c).1, 3, 4

Suggested Topics

Are you eager to expand your knowledge beyond C# Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!