C# Interview Questions - 14 | Snaprecruit.com

C# Interview Questions - 14 | Snaprecruit.com

C SHARP interview questions part 14

C SHARP interview questions part 14

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. Select the operators used for checking the equality in strings:

Correct Answer is : System.Process

2. What does the given code set specifies? public static int Compare(string strA, string strB)

Correct Answer is : There is no limit on the number of levels while nesting namespaces

3. Select the output for given set of code: static void Main(string[] args){ string s1 = "Hello" + "c" + "Sharp"; Console.WriteLine(s1); Console.ReadLine();}

Correct Answer is : data

4. What does the given code set specify? public static int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase)

Correct Answer is : If not mentioned, a namespace takes the name of the current project

5. Which string operation does the below-mentioned method define? public static string Concat(string str0, string str1)

Correct Answer is : Book b = new Book();

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

Correct Answer is : Importing outer namespaces imports inner namespace

7. Did method use to remove whitespace from the string?

Correct Answer is : System.Web

8. What is an iterator?

Correct Answer is : class Program

9. What will be the output of the given code snippet? class MyClass { char[] chrs = { 'A', 'B', 'C', 'D' }; public System.Collections.IEnumerator GetEnumerator() { foreach (char ch in chrs) yield return ch; } } class Program { static void Main(string[] args) { MyClass mc = new MyClass(); foreach (char ch in mc) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); } }

Correct Answer is : All of the mentioned

10. Choose the correct statements about part of given code defined above? public System.Collections.IEnumerator GetEnumerator() { foreach (char ch in chrs) yield return ch; }

Correct Answer is : It is permitted to define a member at namespace level using alias

11. What does the given code snippet specify? class MyClass{ char chrs = 'A' ; public IEnumerator GetEnumerator() { for (int i = 20; i >=0; --i) yield return (char)((chrs + i)); }}class Program{ static void Main(string[] args) { MyClass mc = new MyClass(); foreach (char ch in mc) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); }}

Correct Answer is : #

12. What will the given code snippet specify? class MyClass{ char chrs = 'A' ; public IEnumerator GetEnumerator() { for (int i = 20; i >=0; --i) if (i == 10) yield break; yield return (char)((chrs + i)); }}class Program{ static void Main(string[] args) { MyClass mc = new MyClass(); foreach (char ch in mc) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); }}

Correct Answer is : all of the mentioned

13. What will be the output of the code snippet? class MyClass { int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; public IEnumerator GetEnumerator() { for (int i = 0; i < 20; i++) { if (a[i] % 2 == 0) yield return (int)(a[i]); } } } class Program { static void Main(string[] args) { MyClass mc = new MyClass(); foreach (int i in mc) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); } }

Correct Answer is : All of the mentioned

14. What will be the output of the code snippet? class MyClass { char ch = 'A'; public IEnumerable MyItr(int end) { for (int i = 0 ;i < end ;i++) yield return (char)(ch + i); } public IEnumerable MyItr(int begin, int end) { for (int i = begin ;i < end ;i++) yield return (char)(ch + i); } } class Program { static void Main(string[] args) { MyClass mc = new MyClass(); Console.WriteLine("Iterate the first 7 letters:"); foreach (char ch in mc.MyItr(7)) Console.Write(ch + " "); Console.WriteLine("n"); Console.WriteLine("Iterate letters from F to L:"); foreach (char ch in mc.MyItr(7, 12)) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); } }

Correct Answer is : All of the mentioned

15. What will be the output of the code snippet? class MyClass{ char ch = 'A'; int e = 4; int k = 9; int z = 6; public IEnumerator GetEnumerator() { for (int i = 0; i < 26; i++) { if (i == e*k /z) yield break; yield return (int)(ch + i); } }}class Program{ static void Main(string[] args) { MyClass mc = new MyClass(); foreach(int ch in mc) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); }}

Correct Answer is : pi not define

16. What are the advantages of the named iterator?

Correct Answer is : DEBUG and MYTEST are defined

17. Which of these classes contains only floating point functions?

Correct Answer is : DEBUG and MYTEST are not defined

18. What will be the output of the given code snippet? class Program { static void Main(string[] args) { double x = 2.0; double y = 3.0; double z = Math.Pow( x, y ); Console.WriteLine(z); Console.ReadLine(); } }

Correct Answer is : #error

19. What will be the output of the given code snippet? class Program { static void Main(string[] args) { double x = 4.772; double y = 4.76; double z = Math.Max(x, y); Console.WriteLine(z); Console.ReadLine(); } }

Correct Answer is : #Or

20. What is the value of double consonant ‘E’ defined in Math class?

Correct Answer is : There are multiple constraints on type argument to MyConatiner class

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon