Home » Aptitude Questions and Answers » C# Aptitude Questions and Answers

C# Strings Aptitude Questions and Answers | Set 3

C# Strings Aptitude Questions | Set 3: This section contains aptitude questions and answers on C# Strings.
Submitted by Nidhi, on April 05, 2020

1) Can we create a string object without a new operator?
  1. Yes
  2. No

2) What is the correct output of given code snippets?
static void Main(string[] args)
{
	String str = "sample";

	Console.Write(str.IndexOf('p'));
	Console.Write(str.Length);
}
  1. 46
  2. 36
  3. 37
  4. 47

3) What is the correct output of given code snippets?
static void Main(string[] args)
{
	String str = "sample sample";

	Console.Write(str.IndexOf('p'));
	Console.Write(str.Length);
}
  1. 313
  2. 312
  3. 1012
  4. 1013

4) What is the correct output of given code snippets?
static void Main(string[] args)
{
	String str = "sample sample";

	Console.Write(str.LastIndexOf('p'));
	Console.Write(str.Length);
}
  1. 313
  2. 312
  3. 1012
  4. 1013

5) What is the correct output of given code snippets?
static void Main(string[] args)
static void Main(string[] args)
{
	String str1 = "ABC";
	String str2 = "ABC";

	if (str1.CompareTo(str2))
		Console.WriteLine("Both are equal");
	else
		Console.WriteLine("Both are not equal");
}
  1. Both are equal
  2. Both are not equal
  3. Runtime Exception
  4. Syntax Error






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.