C# Interview Questions - 4 | Snaprecruit.com

C# Interview Questions - 4 | Snaprecruit.com

C SHARP interview questions part 4

C SHARP interview questions part 4

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

Total Questions: 20

1. What does the following code block defines? class Gen { T ob; }

Correct Answer is : none of the mentioned

2. What does the following code set defines? public Gen(T o) { ob = o; }

Correct Answer is : InputStream

3. Select the type argument of an open constructed type?

Correct Answer is : MemoryStream

4. Which among the given classes is present in System.Collection.Generic.namespace?

Correct Answer is : UnmanagedMemoryStream

5. Which of these is a correct way of defining generic method?

Correct Answer is : long Length

6. Which of these type parameters is used for generic methods to return and accept any type of object?

Correct Answer is : FileMode.CreateNew

7. Choose the correct way to call subroutine fun() of the sample class? class a{ public void x(int p, double k) { Console.WriteLine("k : csharp!"); }}

Correct Answer is : FileMode.Create

8. What will be the output of the given code snippet? public class Generic{ Stack stk = new Stack(); public void push(T obj) { stk.Push(obj); } public T pop() { T obj = stk.Pop(); return obj; }}class Program{ static void Main(string[] args) { Generic g = new Generic(); g.push(40); Console.WriteLine(g.pop()); Console.ReadLine(); }}

Correct Answer is : flush()

9. What will be the output of the given code snippet? public class Generic{ Stack stk = new Stack(); public void push(T obj) { stk.Push(obj); } public T pop() { T obj = stk.Pop(); return obj; }}class Program{ static void Main(string[] args) { Generic g = new Generic(); g.push("Csharp"); Console.WriteLine(g.pop()); Console.ReadLine(); }}

Correct Answer is : ReadByte()

10. Assume 2 columns named as Product and Category how can be both sorted out based on first by category and then by product name?

Correct Answer is : 16 bit

11. Choose the wrong statement about the LINQ?

Correct Answer is : I am a human being

12. Choose the namespace in which the interface IEnumerable is declared?

Correct Answer is : var daysArray = days.ToCharArray().Select(c =>c.Tostring()).ToArray();

13. Can we use linq to query against a DataTable?

Correct Answer is : 45355

14. What will be the output of given code snippet? class Program { static void Main(string[] args) { int[] nums = { 1, -2, 3, 0, -4, 5}; var posNums = from n in nums where n >= 0 select n; foreach (int i in posNums) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); }}

Correct Answer is : Compare()

15. Select the namespace which should be included while making use of LINQ operations:

Correct Answer is : TextWriter

16. Select the output for the given code snippet: class Program { static void Main(string[] args) { int[] nums = { 1, -2, 3, 0, -4, 5 }; var posNums = from n in nums where n % 2 ==0 select n; Console.Write("The positive values in nums: "); foreach (int i in posNums) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); } }

Correct Answer is : they operate directly on unicode characters

17. Select the output for given code snippet: class Program{ static void Main(string[] args) { int[] nums = { 1, -2, 3, 0, -4, 5 }; var posNums = from n in nums where n > -5 && n < 6 orderby n descending select n; Console.Write("The positive values in nums: "); foreach (int i in posNums) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); }}

Correct Answer is : StreamReader

18. Select the output for given code snippet: class Program{ static void Main(string[] args) { int[] nums = { 16, 9, 25}; var posNums = from n in nums where n > 0 select Math.Sqrt(n);  Console.Write("The positive values in nums: "); foreach (int i in posNums) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); }}

Correct Answer is : flush()

19. Select the output for given code snippet: class Program{ static void Main(string[] args) { int[] nums = {1}; var posNums = from n in nums wheres n > 0 select Math.Max(78, 9); Console.Write("The largest values in nums: "); foreach (int i in posNums) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); }}

Correct Answer is : int ReadBlock(char[ ] buffer, int index, int count)

20. Which namespace is mostly preferred for the operation of networking in C#?

Correct Answer is : int Read(char[] buffer, int index, int count)

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon