My Report

C# String Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following C# code?

static void Main(string[] args)
{
    string s1 = "Hello" + " I " + "Love" + " ComputerScience ";
    Console.WriteLine(s1);
    Console.ReadLine();
}

2. Which of these operators can be used to concatenate two or more String objects?

3. 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();
 }

4. Which of the following string() method are used to compare two strings with each other?

5. The Method use to remove white space from a string?

6. 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();
 }

7. Correct way to find if contents of two strings are equal?

8. Which of the following statements are correct?

9. Choose the base class for string() method:

10. Which of the following statement is correct about a string in C#.NET?


 

Start practicing “1000 MCQs on C#”, and once you are ready, you can take tests on all topics by attempting our “C# Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.