My Report

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

1. The modifiers used to define an array of parameters or list of arguments is __________

2. Which statement is/are correct?

3. What will be the correct statement in the following C# code?

class trial
{
    int i;
    float d;
}
struct sample
{
    private int x;
    private Single y;
    private trial z;
}
sample s = new sample();

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

 {
     struct abc
     {
         int i;
     }
     class Program
     {
         static void Main(string[] args)
         {
             abc x = new abc();
             abc z;
             x.i = 10;
             z = x;
             z.i = 15;
             console.Writeline(x.i + "  " + y.i)
         }
     }
 }

5. Choose the correct statements about enum used in C#.NET?

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

enum days:int
{
    sunday = -3,
    monday,
    tuesday
}
Console.WriteLine((int)days.sunday);
Console.WriteLine((int)days.monday);
Console.WriteLine((int)days.tuesday);

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;

8. The number of levels of inheritance are?

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

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

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

 class Program
 {
     static void Main(string[] args)
     {
         int i = 5;
         int j;
         method1(ref i);
         method2(out j);
         Console.writeline(i + "  " + j);
     }
     static void method1(ref int x)
     { 
         x = x + x;
     }
     static void method2(out int x)
     {
         x = 6;
         x = x * x;
     }
 }

 

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.