My Report

C# Programming Mock Test 10


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 s1 = "CSHARP";
         String s2 = s1.Replace('H','L');
         Console.WriteLine(s2);
         Console.ReadLine();
     }
 }

Question 1 of 10

Question 2 of 10

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

 static void Main(string[] args)
 {
     string s = " i love you";
     Console.WriteLine(s.IndexOf('l') + "  " + s.lastIndexOf('o') + "  " + s.IndexOf('e'));
     Console.ReadLine();
 }

Question 2 of 10

Question 3 of 10

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

class UnsafeCode
{
    unsafe static void Main()
    {
        int a = 2;
        int b = 4;
        int *a1 = &a;
        int *b1 = &b;
        Console.WriteLine(*a1 + *b1);
    }
}

Question 3 of 10

Question 4 of 10

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

class UnsafeCode
{
    unsafe static void Main()
    {
        int* ptrs = stackalloc int[3];
        ptrs[0] = 1;
        ptrs[1] = 2;
        ptrs[2] = 3;
        for (int i = 2; i >=0; i--)
        Console.WriteLine(ptrs[i]);
        Console.ReadLine();
    }
}

Question 4 of 10

Question 5 of 10

5. After incrementing a float pointer ptr by 1 it would be incremented by __________

Question 5 of 10

Question 6 of 10

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

Question 6 of 10

Question 7 of 10

7. Which operator is commonly used to find the size of the type of C#?

Question 7 of 10

Question 8 of 10

8. Which of these base class are accessible to the derived class members?

Question 8 of 10

Question 9 of 10

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

 class sum   
 {
     public int x;
     public int y;
     public  int add (int a, int b)
    {
        x = a + b;
        y = x + b;
        return 0;
    }
}    
class Program
{
    static void Main(string[] args)
    {
        sum obj1 = new sum();
        sum obj2 = new sum();   
        int a = 2;
        obj1.add(a, a + 1);
        obj2.add(5, a);
        Console.WriteLine(obj1.x + "  " + obj2.y);     
        Console.ReadLine();
    }
}

Question 9 of 10

Question 10 of 10

10. Select the type argument of open constructed type?

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.