My Report

C# Programming Mock Test 4


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. Select the correct match of parameter declaration.

 static Void main(string[] args)
 {
     int a = 5;
     int b = 6;
     float c = 7.2f;
     math (ref a, ref b, ref c);
     Console.WriteLine(a + "  " + b + "  " + c);
 }
 static int math(/*add parameter declaration */)
 {
     a += b;
     b *= (int)c;
     c += a * b;
     return 0;
 }

Question 1 of 10

Question 2 of 10

2. When does a structure variable get destroyed?

Question 2 of 10

Question 3 of 10

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

  enum per
 {
     a, 
     b, 
     c, 
     d, 
 }
 per.a = 10;
 Console.writeline(per.b);

Question 3 of 10

Question 4 of 10

4. Correct code to be added for overloaded operator - for the following C# code?

 class csharp
 {
     int x, y, z;
     public csharp()
     {

     }
     public csharp(int a ,int b ,int c)
     {
         x = a;
         y = b;
         z = c;
     }
     Add correct set of code here
    public void display()
    {
        console.writeline(x + "  " + y + "  " + z);
    }
    class program
    {
        static void Main(String[] args)
        {
            csharp s1 = new csharp(5 ,6 ,8);
            csharp s3 = new csharp();
            s3 = - s1;
            s3.display();
        }
    }
}

Question 4 of 10

Question 5 of 10

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

 
static void Main(string[] args)
{
    int [] a = {1, 2, 3, 4, 5};
    fun(a);
    Console.ReadLine();
}
static void fun(params int[] b )
{
    int[] k = { 3, 4, 7, 8,'\0' };
    for (int i = 0; i < b.Length; i++)
    {
        b[i] = b[i] + k[i] ;
        Console.WriteLine( b[i] + " ");
    }
}

Question 5 of 10

Question 6 of 10

6. Which of the following is the correct way to settle down values into the structure variable 'e' defined in the following C# code snippet?

 struct emp
 { 
     public String name;
     public int age;
     public Single sal;
 }
 emp e = new emp();

Question 6 of 10

Question 7 of 10

7. Which of the following is the correct result for the given statement in the C#.NET statement given below?
p = q

struct employee
{
    private int employee id;
    private string city;
}
employee q = new employee();
employee p;
p = q;

Question 7 of 10

Question 8 of 10

8. Which of the following statements is correct?

Question 8 of 10

Question 9 of 10

9. Choose the correct statement among the following which supports the fact that C# does not allow the creation of empty structures?

Question 9 of 10

Question 10 of 10

10. How to print \\ on the screen?

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.