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. What will be the output of the following C# code?

 static void Main(string[] args)
 {
     int a = 5;
     int b = 0, c = 0;
     method (a,  ref b, ref c);
     Console.WriteLine(b + "  " + c);
     Console.ReadLine();
 }
 static int method(int x, int p, ref int k)
 {
     p = x + x * x;
     k = x * x + p;
     return 0;
 }

2. Choose the wrong statement about structures in C#.NET?

3. Given class sample is inherited by class sample 1. Which are the correct statements about construction of object of class sample?

4. The capability of an object in Csharp to take number of different forms and hence display behaviour as according is known as ___________

5. Which among the following cannot be used as a datatype for an enum in C#.NET?

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

struct book
{
    private String name;
    private int pages;
    private Single price;
}
book b = new book();

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

 static void main(string[] args)
 {
     int i;
     int res = fun (out i);
     console.writeline(res);
     console.readline();
 }
 static int fun(out int i)
 {
     int s = 1;
     i = 7;
     for (int j = 1; j <= i; j++ )
     s = s * j;
     return s;
 } 

8. Which statement is/are correct?

9. How is a string typically processed?

10. Calculate the number of bytes a structure variable s occupies in the memory if it is defined as follows.

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

 

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.