My Report

C# Programming Practice 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

1. Which of these is used as default for a member of a class if no access specifier is used for it?

2. What is the process by which we can control what parts of a program can access the members of a class?

3. Which of these access specifiers must be used for class so that it can be inherited by another subclass?

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

 class UnsafeCode
 {
     unsafe static void Main()
     {
         char[] arr = { 'A', 'B', 'C', 'D', 'E' };
         fixed (char* P = arr)
         {
             int i;
             for (i = 0 ;i < 5 ;i++)
             if (*P % 2 == 0)
             ++*P;
             else
             (*P)++;
             Console.WriteLine(arr);
         }
         Console.ReadLine();
     }
 }

5. 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!");
    }
}

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

7. Consider an integer pointer . *a.++*a will increment ___________ while *a++ will increment __________

8. A structure pointer points to __________

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

10. 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();
     }
 }

 

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.