My Report

C# Programming Mock Test 8


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

Question 1 of 10

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

class Program
{
    static void Main(string[] args)
    {
        string[] strs = {"alpha", "beta", "gamma"};
        var chrs = from str in strs
                   let chrArray = str.ToCharArray()
                   from ch in chrArray
                   orderby ch
                   select ch;
        Console.WriteLine("The individual characters in sorted order:");
        foreach (char c in chrs) 
        Console.Write(c + " ");
        Console.WriteLine();
        Console.ReadLine();
    }
}

Question 1 of 10

Question 2 of 10

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

class Program
{
    static void Main(string[] args)
    {
        float x = 3.14F;
        int y = (int)Math.Abs(x);
        Console.WriteLine(y);
        Console.ReadLine();
    }
}

Question 2 of 10

Question 3 of 10

3. What does the following property signify?

MemberTypes MemberType

Question 3 of 10

Question 4 of 10

4. Which among the following is the correct way to access all the elements of the Stack collection created using the C#.NET code snippet given below?

Stack st = new Stack();
st.Push(10);
st.Push(20);
st.Push(-5);
st.Push(30);
st.Push(6);

Question 4 of 10

Question 5 of 10

5. What will be the output of the following C# 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();
    }
}

Question 5 of 10

Question 6 of 10

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

Question 6 of 10

Question 7 of 10

7. What does the following C# code signify?

expr is type

Question 7 of 10

Question 8 of 10

8. Select the interfaces implemented by array class.

Question 8 of 10

Question 9 of 10

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

Question 9 of 10

Question 10 of 10

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

 class Program
 {
     static void Main(string[] args)
     {
         int[] nums = { 1, -2, 3, 0, -4, 5 };
         var posNums = nums.Where(n => n > 0).Select(r => r*2).
                       OrderByDescending(r=>r);
         Console.Write("The positive values in nums: ");
         foreach(int i in posNums) 
         Console.Write(i + " ");
         Console.WriteLine();
         Console.ReadLine();
     }
 }

Question 10 of 10


 

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.