Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     int[] arr = new int[] {1, 2, 3, 4, 5};     fun1(ref arr);     Console.ReadLine();  } static void fun1(ref int[] array) {     for (int i = 0; i < array.Length; i++)     {         array[i] = array[i] + 5;         Console.WriteLine(array[i] + " ");     } }

Choices:
- 6 7 8 9 10
- 15 17 8 8 20
- 15 17 8 29 20
- Syntax error while passing reference of array variable


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     int []a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};     func(ref a);     Console.ReadLine(); } static void func(ref int[] x) {     Console.WriteLine(" numbers are:");     for (int i = 0; i < x.Length; i++)     {         if (x[i] % 2 == 0)         {             x[i] = x[i] + 1;             Console.WriteLine(x[i]);         }     } }

Choices:
- numbers are : 2 4 6 8 10
- numbers are : 3 5 7 9 11
- numbers are : 2 3 4 5 6
- none of the mentioned


Question:
What will be the output of the following C# code?
  static void Main(string[] args)  {      int X = 0;      if (Convert.ToBoolean(X = 0))      Console.WriteLine("It is zero");      else       Console.WriteLine("It is not zero");      Console.ReadLine();  }

Choices:
- It is zero
- It is not zero
- Infinite loop
- None of the mentioned


Question:
What will be the output of the following C# code?
    static void Main(string[] args)    {       int X = 6,Y = 2;       X  *= X / Y;       Console.WriteLine(X);       Console.ReadLine();    }

Choices:
- 12
- 6
- 18
- Compile time error


Question:
What will be the output of the following C# code?
    static void Main(string[] args)    {        int x = 4 ,b = 2;        x -= b/= x * b;        Console.WriteLine(x + " " + b);        Console.ReadLine();    }

Choices:
- 4 2
- 0 4
- 4 0
- 2 2


Question:
What will be the output of the following C# code?
   static void Main(string[] args)   {       int x = 8;       int b = 16;       int C = 64;       x /= b /= C;       Console.WriteLine(x + " " + b+ " " +C);       Console.ReadLine();   }

Choices:
- 8 2 32
- 32 4 8
- 32 2 8
- Compile time error


Question:
What will be the output of the following C# code?
   static void Main(string[] args)   {       int x = 8;       int b = 16;       int C = 64;       x /= b /= C;       Console.WriteLine(x + " " + b+ " " +C);       Console.ReadLine();   }

Choices:
- 8 2 32
- 32 4 8
- 32 2 8
- Compile time error


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     int a = 5;     int s = 0, c = 0;     Mul (a, ref s, ref c);     Console.WriteLine(s + "t " +c);     Console.ReadLine(); } static void Mul (int x, ref int ss, ref int cc) {     ss = x * x;     cc = x * x * x; }

Choices:
- 125 25
- 25 125
- Compile time error
- 0 0


Question:
What will be the output of the following C# code?
static void Main(string[] args){    Mul();    m();    Console.ReadLine();}static void Mul(){    Console.WriteLine("4");}static void m(){    Console.WriteLine("3");    Mul();}

Choices:
- 4 3 3
- 4 4 3
- 4 3 4
- 3 4 4


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     m();     Console.ReadLine(); } static void m() {     Console.WriteLine("HI");     m(); }

Choices:
- HI HI HI
- HI
- Stack overflow exception
- Compile time error


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     int y = 3;     y++;     if (y <= 5)     {          Console.WriteLine("hi");         Main(args);     }     Console.ReadLine(); }

Choices:
- hi hi
- hi
- Stack overflow exception
- None of the mentioned


Question:
What will be the output of the following C# code?
 public static void Main(string[] args) {     p();     void p()     {         Console.WriteLine("hi");     } }

Choices:
- Compile time error
- hi
- hi infinite times
- None of the mentioned


Question:
Correct way to define object of sample class in which C# code will work correctly is:
 class abc {     int i;     float k;     public abc(int ii, float kk)     {           i = ii;         k = kk;     } }

Choices:
- abc s1 = new abc(1);
- abc s1 = new abc();
- abc s2 = new abc(1.4f);
- abc s2 = new abc(1, 1.4f);


Question:
What will be the output of the following C# code?
  class sample  {      int i;      double k;      public sample (int ii, double kk)      {          i = ii;          k = kk;          double j = (i) + (k);          Console.WriteLine(j);      }      ~sample()      {          double j = i - k;          Console.WriteLine(j);      }  }  class Program  {      static void Main(string[] args)      {          sample s = new sample(8, 2.5);          Console.ReadLine();      }  }

Choices:
- 0  0
- 10.5 0
- Compile time error
- 10.5 5.5


Question:
What will be the output of the following C# code?
   class box   {       public int volume;       int width;       int height;       int length;       public box ( int w, int h, int l)       {           width = w;           height = h;           length = l;       }      public ~box()      {          volume = width * length * height;       }   }      class Program  {      static void Main(string[] args)      {          box b = new box(4, 5, 9);          Console.WriteLine(b.volume);          Console.ReadLine();      }   }

Choices:
- 0
- 180
- Compile time error
- None of the mentioned


Question:
What will be the output of the following C# code?
  class box  {      public int volume;      int width;      int height;      int length;      public box ( int w, int h, int l)      {          this.width = w;          this.height = h;          this.length = l;      }      ~ box()      {          volume = this.width * this.length * this.height;          console.writeline(volume);      }  }      class Program  {      public  static void Main(string[] args)      {          box b = new box(4, 5, 9);          Console.ReadLine();      }  }

Choices:
- 0
- Code executes successfully but prints nothing
- Compile time error
- 180


Question:
What will be the output of the following C# code?
static void Main(string[] args){    int i, j;    int[, ] arr = new int[ 3, 3];    for (i = 0; i < 3; ++i)    {        for (j = 0; j < 3; ++j)        {            arr[i, j] = i * 2 + i * 2;            Console.WriteLine(arr[i, j]);        }        Console.ReadLine();    }}

Choices:
- 0, 0, 0  4, 4, 4  8, 8, 8
- 4, 4, 4  8, 8, 8   12, 12, 12
- 8, 8, 8  12, 12, 12  16, 16, 16
- 0, 0, 0  1, 1, 1  2, 2, 2


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     char A = 'K';     char B = Convert.ToChar(76);     A++;     B++;     Console.WriteLine(A+ "  " +B);     Console.ReadLine(); }

Choices:
- M L
- U L
- L M
- A B


Question:
Complete the following C# code with “foreach condition”.
int[][]a = new int[2][];a[0] = new int[3]{3, 4, 2};a[1] = new int[2]{8, 5};foreach( int[]i in a){/* add for loop */console.write( j+ " ");console.writeline();}

Choices:
- foreach (int j = 1;(j(<)(a(0).GetUpperBound)); (j++));
- foreach (int j = 1;(j(<)(a.GetUpperBound(0))); (j++));
- foreach (int j in a.Length);
- foreach (int j in i);


Question:
What will be the output of the following C# code?
static void Main(string[] args){    double a = 345.09;    byte c = (byte) a;    Console.WriteLine(c);    Console.ReadLine();}

Choices:
- 98
- 89
- 88
- 84


Question:
Which statement is correct about following C# code?
int[, ]a={{5, 4, 3},{9, 2, 6}};

Choices:
- ’a’ represents 1-D array of 5 integers
- a.GetUpperBound(0) gives 9
- ’a’ represents rectangular array of 2 columns and 3 arrays
- a.GetUpperBound(0) gives 2


Question:
What will be the output of the following C# code?
static void Main(string[] args){    Program p = new Program();    p.display(2, 3, 8);    int []a = { 2, 56, 78, 66 };    Console.WriteLine("example of array");    Console.WriteLine("elements added are");    p.display(a);    Console.ReadLine();}public void display(params int[] b){    foreach (int i in b)    {        Console.WriteLine("ARRAY IS HAVING:{0}", i);    }}

Choices:
- Compile time error
- Run time error
- Code runs successfully but prints nothing
- Code runs successfully and prints given on console


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     string s1 = " Cshr ";     string s2 = s1.Insert(3 , " a ");     string s3 = s2.Insert(5 , " p ");     for (int i = 0;i < s3.Length; i++)     Console.WriteLine(s3[i]);     Console.ReadLine(); }

Choices:
- Cshar
- CsharP
- Csharp
- Cshrap


Question:
What will be the output of the following C# code?
static void Main(string[] args){    string s1 = "Hello" + " I " + "Love" + " ComputerScience ";    Console.WriteLine(s1);    Console.ReadLine();}

Choices:
- HelloILoveComputerScience
- Hello I Love ComputerScience
- Compile time error
- Hello


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     string s1 = "Hello I Love Csharp ";     Console.WriteLine(Convert.ToChar( (s1.IndexOf('I') - s1.IndexOf('l')) * s1.IndexOf('p'));     Console.ReadLine(); }

Choices:
- I
- Hello I
- Love
- H


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     String obj = "hello";     String obj1 = "world";        String obj2 = obj;     Console.WriteLine (obj.Equals(obj2) + "  " + obj2.CompareTo(obj) );     Console.ReadLine(); }

Choices:
- True True
- False False
- True 0
- False 1


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     String obj = "hello";     String obj1 = "world";        String obj2 = obj;     string s = obj+" "+obj1;     Console.WriteLine(s.IndexOf('r'));     Console.ReadLine(); }

Choices:
- 7
- 8
- 9
- 10


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     String obj = "hello";     String obj1 = "world";        String obj2 = obj;     string s = obj + "  " + obj1;     Console.WriteLine(s.Substring(6 ,5));     Console.ReadLine(); }

Choices:
- hello
- orld
- world
- o world


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     String obj = "hello";     String obj1 = "worn";        String obj2 = obj;     Console.WriteLine(obj + "  " + (obj1.Replace('w' ,'c')));     Console.ReadLine(); }

Choices:
- hello hello
- hello worn
- hello corn
- hello


Question:
What will be the output of the following C# code?
 class Program {     static void Main(string[] args)     {          String c = "i love Csharp";         bool a;         a = c.StartsWith("I");         Console.WriteLine(a);         Console.ReadLine();     } }

Choices:
- true
- false
- 0
- 1


Question:
What will be the output of the following C# code?
class Program{    static void Main(string[] args)    {         String s1 = "I love You";        String s2 = s1;        Console.WriteLine((s1 == s2) + " " + s1.Equals(s2));        Console.ReadLine();    }}

Choices:
- true true
- false false
- true false
- false true


Question:
What will be the output of the following C# code?
 class Program {     static void Main(string[] args)     {          String []chars = {"z", "x", "y", "z", "y"};         for (int i = 0; i < chars.Length; ++i)         for (int j = i + 1; j < chars.Length; ++j)         if(chars[i].CompareTo(chars[j]) == 0)         Console.WriteLine(chars[j]);         Console.ReadLine();     } }

Choices:
- zx
- xy
- zy
- yz


Question:
What will be the output of the following C# code?
String a = "Csharp";String b = "CSHARP";int c;c = a.CompareTo(b);Console.WriteLine(c);

Choices:
- 0
- 1
- -2
- -1


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     String a = "Ilove";     String b = "CSHARP";     b = string.Concat(a, '  ', b);     Console.WriteLine(b);     Console.ReadLine(); }

Choices:
- IloveCSHARP
- I loveCSHARP
- Ilove
- Ilove CSHARP


Question:
What will be the output of the following C# code?
  static void Main(string[] args)  {      String a = "Ilove";      String b = "CSHARP";      b = string.Concat(a,' ',b);      string d = b.TrimStart('I', 'l', 'o', 'H');      Console.WriteLine(d);      Console.ReadLine();  }

Choices:
- Ilove CSHARP
- love CSHARP
- ve CSHARP
- ve CSARP


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     String c = "  Hello Computer ";     String a = c.Trim();     Console.WriteLine("\"" + s + "\""); }

Choices:
- ” Hello Computer ”
- “HelloComputer”
- “Hello Computer”
- Hello Computer


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     String c = "Hello";     String a = c + "Bye";     Console.WriteLine(a);     Console.ReadLine(); }

Choices:
- “Hello Bye”
- “HelloBye”
- Hello Bye
- HelloBye


Question:
What will be the output of the following C# code?
static void Main(string[] args){    String c = "Hello";    String a ;    a = c.Replace('l', 'w');    Console.WriteLine(a);    Console.ReadLine();}

Choices:
- Helloll
- Hewlo
- Helwo
- Hewwo


Question:
What will be the output of the following C# code snippet?
  static void Main(string[] args)  {      String c = "Hello i love you";      String a ;      a = c.Substring(12, 3);      Console.WriteLine(a);      Console.ReadLine();  }

Choices:
- ove
- you
- yo
- love you


Question:
What will be the output of the following C# code snippet?
 static void main(String args[]) {     char chars[] = {'x', 'y', 'z'};     String s = new String(chars);     Console.WriteLine(s); }

Choices:
- x
- xy
- z
- xyz


Question:
Choose the effective stringBuilder method which helps in producing output for the following C# code?
 static void Main(string[] args) {     StringBuilder s = new StringBuilder("object");     s./*______*/("Oriented Language");     Console.WriteLine(s);     Console.ReadLine(); }Output : objectOriented Language

Choices:
- Insert()
- Add()
- Append()
- Join()


Question:
What will be the output of the following C# code?
  static void Main(string[] args)  {      string s = " i love you";      Console.WriteLine(s.IndexOf('l') + "  " + s.lastIndexOf('o') + "  " + s.IndexOf('e'));      Console.ReadLine();  }

Choices:
- 3 5 7
- 4 5 6
- 3 9 6
- 2 4 6


Question:
What will be the output of the following C# code snippet?
 static void Main(string[] args) {     string c = "hello";     string  c1 = c.Remove(1);     Console.WriteLine(c1);     Console.ReadLine(); }

Choices:
- ello
- h
- hell
- none of the mentioned


Question:
What will be the output of the following C# code?
 class sum    {     public int x;     private int y;     public void math(int a, int b)     {         x = a * 4;         y = b;     } }     class Program {     static void Main(string[] args)     {         sum p = new sum();            p.math(12, 30);         Console.WriteLine(p.x + "  " + p.y);         Console.ReadLine();     } }

Choices:
- 48, 30
- 48, 0
- 0, 0
- Compile time error


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

Choices:
- 6, 9
- 5, 9
- 9, 10
- 3, 2


Question:
What will be the output of the following C# code?
 class math {     public int a,b;     public math(int i,  int j)     {         a = i;         b = j;     }     public  void sum(math m)     {         m.a *= 2;         m.b += 2;     } }     class Program {     static void Main(string[] args)     {         math t = new math(20,  10);         t.sum(t);         Console.WriteLine(t.a + "  " + t.b);            Console.ReadLine();     } }

Choices:
- 10, 20
- 20, 10
- 40, 12
- 5, 40


Question:
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;     } }

Choices:
- 36, 10
- 10, 36
- 0, 0
- 36, 0


Question:
Which method does following C# code explains?
 static void Main(string[] args) {     int a = 10, b = 20;     method(ref a,  ref b);     console.writeline(a + "  " + b); } static void swap(ref int i,  ref int j) {       int t;     t = i;     i = j;     j = t; }

Choices:
- Call by reference
- Call by value
- Output parameter
- parameter arrays


Question:
What will be the output of the following C# code?
 static void main(string[] args) {     int []arr = new int[]{ 1, 2, 3, 4, 5};     fun (ref arr);     for (int i = 0; i < arr.Length ; i++)     Console.WriteLine( arr[i] + "  "); } static void fun(ref int[]a) {     a = new int[6];     a[3] = 32;     a[1] = 24; }

Choices:
- 0, 0, 32, 0, 0, 0
- 0, 24, 0, 32, 0, 0
- 24, 0, 32, 0, 0, 0
- 0, 0, 32, 0, 0, 0


Question:
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; }

Choices:
- 4490
- 5040
- 5400
- 3500


Question:
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; }

Choices:
- 30, 55
- 55, 30
- Compile time error
- 0, 0


Question:
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; }

Choices:
- ref int a,  int b,  ref float c
- ref int a,  ref float c,  ref int b
- ref int a,  ref int b,  float c
- ref int a,  ref int b,  ref float c


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     object[] a = {" 1 ", 4.0f, " harsh "};     fun(a);     Console.ReadLine(); } static void fun(params object[] b) {     for (int i = 0; i < b.Length - 1; i++)         Console.WriteLine(b[i] + " "); }

Choices:
- 1 4.0 harsh
- 1 4
- 1 4 hars
- 1 4 harsh


Question:
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] + " ");    }}

Choices:
- Compile time error
- 3, 4, 7, 8, 5
- 3, 4, 7, 8, 5, 1, 2, 3, 4, 5
- 4, 6, 10, 12, 5


Question:
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 ) {     for (int i = 0; i < b.Length; i++)     {         b[i] = b[i] * 5 ;         Console.WriteLine(b[i] + "");     } }

Choices:
- 1, 2, 3, 4, 5
- 5, 10, 15, 20, 25
- 5, 25, 125, 625, 3125
- 6, 12, 18, 24, 30


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     int[] a = { 2, 21, 34, 46, 85, 88, 90};     fun(a);     Console.WriteLine(a + " ");     Console.ReadLine(); } static void fun(params int [] b ) {     int [] c = { 1, 2, 3, 4, 5, 6, 7};     int i ;     for (i = 0 ;i < b.Length ;i++)     if (b[i] % 2 == 0)     {         c[i] = b[i];     }     Console.WriteLine("even numbers are:");     for (i = 0 ;i <= b.Length ;i++)     {         Console.WriteLine(c[i]);     } }

Choices:
- Compile time error
- 2, 21, 34, 4, 6, 46, 88, 90
- 2, 4, 34, 46, 6, 88, 90
- 2, 34, 46, 88, 90


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     int[] x = { 80, 82, 65, 72, 83, 67 };     fun(x);     Console.ReadLine(); } static void fun(params int [] b ) {     int i;     for (i = 5; i >=0 ; i--)     {         Console.WriteLine(Convert.ToChar(b[i]));     } }

Choices:
- 67 83 72 65 82 80
- P R A H S C
- C S H A R P
- 80 82 65 72 83 67


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     int[] x = {65, 66, 67, 68, 69, 70};     fun(x);     Console.ReadLine(); } static void fun(params int[] b ) {     int i;     for (i = 5; i > 0 ; i--)     {         b[i] = b[i] + 32;         Console.WriteLine(Convert.ToChar(b[i]));     } }

Choices:
- A, B, C, D, E, F
- F, E, D, C, B, A
- f, e, d, c, b
- b, c, d, e, f


Question:
What will be the output of the following C# code?
 public class sample {     public static int x = 100;     public static int y = 150;  } public class newspaper :sample {     new public static int x = 1000;     static void Main(string[] args)     {         console.writeline(sample.x + "  " + sample.y + "  " + x);     } }

Choices:
- 100 150 1000
- 1000 150 1000
- 100 150 1000
- 100 150 100


Question:
What will be the Correct statement of the following C# code?
 public class maths {     public int x;     public virtual void a()     {      }  } public class subject : maths {     new public void a()     {      }  }

Choices:
- The subject class version of a() method gets called using sample class reference which holds subject class object
- subject class hides a() method of base class
- The code replaces the subject class version of a() with its math class version
- None of the mentioned


Question:
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();

Choices:
- New structure can be inherited from struct book
- When the program terminates, variable b will get garbage collected
- The structure variable ‘b’ will be created on the stack
- When the program terminates,  variable b will get garbage collected


Question:
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();

Choices:
- trial object referred by z is created on the stack
- z is created on the heap
- Both s and z will be created on the heap
- s will be created on the stack


Question:
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();

Choices:
- 24 bytes
- 8 bytes
- 16 bytes
- 12 bytes


Question:
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;

Choices:
- Elements of ‘q’ will be copied into corresponding elements of p
- Address stored in q will get copied into p
- Address of first element of q will get copied into p
- Once assignment is over. q will go out of scope and hence get exited forever


Question:
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)         }     } }

Choices:
- 10 10
- 10 15
- 15 10
- 15 15


Question:
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);

Choices:
- -3 0 1
- 0 1 2
- -3 -2 -1
- sunday monday tuesday


Question:
What will be the correct statement of the following C# code?
enum color:byte{    yellow = 500,    green = 1000,    pink = 1300}

Choices:
- byte value cannot be assigned to enum elements
- enum elements should always take successive values
- enum must always be of int type
- When the valid range of byte exceeds, the compiler will report an error


Question:
What will be the output of the following C# code?
  enum per {     a,      b,      c,      d,  } per.a = 10; Console.writeline(per.b);

Choices:
- 11
- 1
- 2
- compile time error


Question:
What will be the output of the following C# code?
enum color:int{    red,    green,    blue = 5,    cyan,    pink = 10,    brown}console.writeline((int)color.green);console.writeline((int)color.brown);

Choices:
- 2 10
- 2 11
- 1 11
- 1 5


Question:
What will be the output of the following C# code?
enum letters{    a,    b,    c} letters l;l = letters.a;Console.writeline(l);

Choices:
- -1
- 0
- a
- letters.a


Question:
What will be the output of the following C# code?
 enum colors {     red,     black,     pink } colors s = colors.black; type t; t = c.GetType(); string[] str; str = Enum.GetNames(t); Console.WriteLine(str[0]);

Choices:
- 0
- black
- red
- 1


Question:
What does the following C# code signify?
 class a {    } class b : a {     variable declaration;     method declaration; }

Choices:
- Declaration of a base class
- Declaration of a subclass
- Declaration of base class & subclass and how subclass inherits the base class
- None of the mentioned


Question:
What will be the output of the following C# code?
 class sample {     public  int i;     void display()      {         Console.WriteLine(i);     }}    class sample1 : sample {    public  int j;    public void display()     {        Console.WriteLine(j);    }}    class Program{    static void Main(string[] args)    {        sample1 obj = new sample1();        obj.i = 1;        obj.j = 2;        obj.display();        Console.ReadLine();    }}

Choices:
- 1
- 3
- 2
- Compile Time error


Question:
What will be the Correct statement in the following C# code?
class sample{    protected int index;    public sample()    {        index = 0;    }}class sample 1: sample{    public void add()    {        index += 1;    }}class Program{    static void Main(string[] args)    {        sample 1 z = new sample 1();        z . add();    }}

Choices:
- Index should be declared as protected if it is to become available in inheritance chain
- Constructor of sample class does not get inherited in sample 1 class
- During constructing an object referred to by z, Firstly constructor of sample class will be called followed by constructor of sample 1 class
- All of the mentioned


Question:
What will be size of the object created depicted by C# code snippet?
 class baseclass {     private int a;     protected int b;     public int c; } class derived : baseclass {     private int x;     protected int y;     public int z; } class Program {     static Void Main(string[] args)     {         derived a = new derived();     } }

Choices:
- 20 bytes
- 12 bytes
- 16 bytes
- 24 bytes


Question:
What will be the output of the following C# code?
class sample{    public sample()    {        Console.WriteLine("THIS IS BASE CLASS constructor");    } }    public class sample1 : sample { }    class Program{    static void Main(string[] args)    {        sample1 obj = new sample1();        Console.ReadLine();    }}

Choices:
- Code executes successfully prints nothing
- This is base class constructor
- Compile time error
- None of the mentioned


Question:
Select the statement which should be added to the current C# code to get the output as 10 20?
class baseclass{    protected int a = 20;}class derived : baseclass{    int a = 10;    public void math()    {         /* add code here */    }   }

Choices:
- Console.writeline( a + ”  ” + this.a);
- Console.Writeline( mybase.a + ”  ” + a);
- console.writeline(a + ”  ” + base.a);
- console.writeline(base.a + ”  ” + a);


Question:
Which C# statement should be added in function a() of class y to get output “i love csharp”?
 class x {     public void a()     {         console.write("bye");     } } class y : x {     public void a()     {     /* add statement here */         console.writeline("  i love csharp ");     } } class program {     static void main(string[] args)     {         y obj =  new obj();         obj.a();     } }

Choices:
- x.a();
- a();
- base.a();
- x::a();


Question:
What will be the output of the following C# code?
class A {    public int i;    protected int j;}    class B : A {    public int j;    public void display()     {        base.j = 3;        Console.WriteLine(i + " " + j);    }}    class Program{    static void Main(string[] args)    {        B obj = new B();        obj.i = 1;        obj.j = 2;        obj.display();             Console.ReadLine();    }}

Choices:
- 2 1
- 1 0
- 0 2
- 1 2


Question:
What will be the output of the following C# code?
 class A {     public int i;     private int j; }      class B :A  {     void display()      {         base.j = base.i + 1;         Console.WriteLine(base.i + "  " + base.j);     }}    class Program{    static void Main(string[] args)    {        B obj = new B();        obj.i = 1;        obj.j = 2;        obj.display();             Console.ReadLine();    }}

Choices:
- 1, 3
- 2, 3
- 1, 2
- compile time error


Question:
What will be the output of the following C# code?
 class maths {     public int x;     public double y;     public int add(int a, int b)     {         x = a + b;         return x;     }     public int add(double c, double d)     {         y = c + d;         return (int)y;     }     public maths()     {         this.x = 0;         this.y = 0;     } }    class Program{    static void Main(string[] args)    {        maths obj = new maths();        int a = 4;        double b = 3.5;        obj.add(a, a);        obj.add(b, b);        Console.WriteLine(obj.x + " " + obj.y);        Console.ReadLine();    }}

Choices:
- 4,  3.5
- 8,  0
- 7.5,  8
- 8,  7


Question:
What will be the output of the following C# code?
 class maths {     public int fun(int k, int y)     {         return k + y;     }     public int fun1(int t, float z)     {         return (t+(int)z);     } }     class Program {     static void Main(string[] args)     {         maths obj = new maths();         int i;         int b = 90;         int c = 100;         int d = 12;         float l = 14.78f;         i = obj.fun(b, c);         Console.WriteLine(i);         int j = (obj.fun1(d,  l));         Console.WriteLine(j);         Console.ReadLine();     } }

Choices:
- 190,  26.78f
- 0,  26.78f
- 190,  26
- 190,  0


Question:
What will be the output of the following C# code?
 class maths {     public int fun(int ii)     {         return(ii > 0 ? ii :ii * -1);     }     public long fun(long ll)     {         return(ll > 0 ? ll :ll * -1);     }     public double fun( double dd)     {         return(dd > 0 ? dd :dd * -1);     } }     class Program {     static void Main(string[] args)     {         maths obj = new maths();         int i = -25;         int j ;         long l = -100000l ;         long m;         double d = -12.34;         double e;         j = obj.fun(i);         m = obj.fun(l);         e = obj.fun(d);         Console.WriteLine(j + "  " + m + "  " + e);         Console.ReadLine();     } }

Choices:
- 1 1 1
- 0 0 0
- 25 100000 12.34
- -25 -100000 -12.34


Question:
What will be the output of the following C# code?
 class A {     public int i;     public void display()      {         Console.WriteLine(i);     } }     class B: A  {     public int j;     public void display()      {         Console.WriteLine(j);     } }     class Program {     static void Main(string[] args)     {         B obj = new B();         obj.i = 1;         obj.j = 2;         obj.display();         Console.ReadLine();     } }

Choices:
- 0
- 2
- 1
- Compile time error


Question:
What will be the output of the following C# code?
 class A  {     public virtual void display()      {         Console.WriteLine("A");     }     }     class B: A  {    public override void display()     {        Console.WriteLine(" B ");    }  }    class Program{    static void Main(string[] args)    {        A obj1 = new A();        B obj2 = new B();        A r;        r = obj1;        r.display();        r = obj2;        r.display();             Console.ReadLine();    }}

Choices:
- A, A
- B, B
- Compile time error
- A, B


Question:
What will be the output of the following C# code?
 class a {     public  void fun()     {         Console.WriteLine("base method");     } } class b: a {     public new void fun()     {         Console.WriteLine(" derived method ");     } } class Program {     static void Main(string[] args)     {         b k = new b();         k.fun();         Console.ReadLine();     } }

Choices:
- Base method
- Derived method
- Code runs successfully prints nothing
- Compile time error


Question:
What will be the output of the following C# code?
 class maths {     public int length;     public int breadth;     public maths(int x, int y)     {         length = x;         breadth = y;         Console.WriteLine(x + y);     }     public maths(double x, int y)     {         length = (int)x;         breadth = y;         Console.WriteLine(x * y);     } }class Program{    static void Main(string[] args)    {        maths m = new maths(20, 40);        maths k = new maths(12.0, 12);        Console.ReadLine();    }}

Choices:
- 60, 24
- 60, 0
- 60, 144
- 60, 144.0


Question:
What will be the output of the following C# code?
 class maths {     public int length;     public int breadth;     public  maths(int x)     {         length = x + 1;     }     public maths(int x, int y)     {         length = x + 2;     } } class Program {     static void Main(string[] args)     {         maths m = new maths(6);         maths k = new maths(6, 2);         Console.WriteLine(m.length);         Console.WriteLine(k.length);         Console.ReadLine();     } }

Choices:
- 8, 8
- 0, 2
- 8, 10
- 7, 8


Question:
What will be the output of the following C# code?
class maths{    int i;    public maths(int x)    {        i = x;        Console.WriteLine(" hello: ");    }}class maths1 : maths{    public  maths1(int x) :base(x)    {        Console.WriteLine("bye");    }}class Program{    static void Main(string[] args)    {        maths1 k = new maths1(12);        Console.ReadLine();    }}

Choices:
- hello bye
- 12 hello
- bye 12
- Compile time error


Question:
What will be the output of the following C# code?
 class maths {     int i;     public maths(int ii)     {         ii = 12;         int j = 12;         int r = ii * j;         Console.WriteLine(r);     } } class maths1 : maths {     public maths1(int u) :base(u)     {         u = 13;         int h = 13;         Console.WriteLine(u + h);     } } class maths2 : maths1 {     public maths2(int k) :base(k)     {         k = 24;         int o = 6 ;         Console.WriteLine(k /o);     } } class Program {     static void Main(string[] args)     {         maths2 t = new maths2(10);         Console.ReadLine();     } }

Choices:
- 4, 26, 144
- 26, 4, 144
- 144, 26, 4
- 0, 0, 0


Question:
What will be the output of the following C# code?
  class maths  {      static maths()      {          int s = 8;          Console.WriteLine(s);      }      public  maths(int f)      {          int h = 10;          Console.WriteLine(h);      }  }  class Program  {      static void Main(string[] args)      {          maths p = new maths(0);          Console.ReadLine();      }  }

Choices:
- 10, 10
- 0, 10
- 8, 10
- 8, 8


Question:
What will be the output of the following C# code?
 namespace ConsoleApplication4 {        abstract class A      {         int i;         public  abstract void display();     }         class B: A      {         public  int j;         public override void display()          {             Console.WriteLine(j);         }     }         class Program     {         static void Main(string[] args)         {             B obj = new B();             obj.j = 2;             obj.display();             Console.ReadLine();         }     } }

Choices:
- 0
- 2
- Compile time error
- 1


Question:
What will be the output of the following C# code?
 namespace ConsoleApplication4 {     abstract class A     {         public int i ;         public int j ;         public abstract void display();     }         class B: A         {         public int j = 5;         public override void display()          {             this.j = 3;             Console.WriteLine(i + "  " + j);         }     }         class Program     {         static void Main(string[] args)         {             B obj = new B();             obj.i = 1;             obj.display();                  Console.ReadLine();         }     } }

Choices:
- 1, 5
- 0, 5
- 1, 0
- 1, 3


Question:
What will be the output of the following C# code?
 namespace ConsoleApplication4 {     public abstract class A     {         public int i = 7;         public abstract void display();     }         class B: A      {         public int j;         public override void display()          {             Console.WriteLine(i);             Console.WriteLine(j);         }     }         class Program     {         static void Main(string[] args)         {             B obj = new B();             A obj1 = new B();             obj.j = 1;             obj1.i = 8;             obj.display();             Console.ReadLine();         }     } }

Choices:
- 0, 8
- 1, 8
- 1, 7
- 7, 1


Question:
What will be the output of the following C# code?
 namespace ConsoleApplication4 {     class A     {         public int i;         public void display()         {             Console.WriteLine(i);         }     }         class B: A      {         public int j;         public void display()          {             Console.WriteLine(j);         }     }         class Program     {         static void Main(string[] args)         {             B obj = new B();             obj.j = 1;             obj.i = 8;             obj.display();             Console.ReadLine();         }     } }

Choices:
- 8, 1
- 8
- 1
- 1, 8


Question:
What will be the Correct statement in the following C# code?
interface a1{    void f1();    int f2();}class a :a1{    void f1()    {    }    int a1.f2()    {    }}

Choices:
- class a is an abstract class
- A method table would not be created for class a
- The definition of f1() in class a should be void a1.f1()
- None of the mentioned


Question:
What will be the Correct statement in the following C# code?
 interface a1 {     void f1();     void f2(); } class a :a1 {      private int i;     void a1.f1()     {     } }

Choices:
- Class a could not have an instance data
- Class a is an abstract class
- Class a fully implements the interface a1
- None of the mentioned


Question:
What will be the Correct statement in the following C# code?
 interface abc {     String FirstName     {         get;         set;     }    String LastName    {        get;        set;    }    void print();    void stock();    int fun();}

Choices:
- Functions should be declared inside an interface
- It is workable code
- Properties cannot be declared inside an interface
- None of the mentioned


Question:
What will be the output of the following C# code?
 interface calc {     void cal(int i); } public  class maths :calc  {     public int x;     public void cal(int i)      {         x = i * i;                 } } class Program {     public static void Main(string[] args)     {                     display arr = new display();         arr.x = 0;               arr.cal(2);         Console.WriteLine(arr.x);         Console.ReadLine();     } }

Choices:
- 0
- 2
- 4
- None of the mentioned


Question:
What will be the output of the following C# code?
 interface calc {     void cal(int i); } class displayA :calc  {     public int x;     public void cal(int i)      {         x = i * i;                 } } class displayB :calc {     public int x;     public void cal(int i)     {         x = i / i;     } } class Program {     public static void Main(string[] args)     {                     displayA arr1 = new displayA();         displayB arr2 = new displayB();         arr1.x = 0;         arr2.x = 0;         arr1.cal(2);         arr2.cal(2);         Console.WriteLine(arr1.x + " " + arr2.x);         Console.ReadLine();     } }

Choices:
- 0 0
- 2 2
- 4 1
- 1 4


Question:
Arrange the following overloaded operators in increasing order of precedence?
 %, <<, &, /, +


Question:
What will be the output of the following C# code?
 class recursion  {     int fact(int n)      {         int result;         if (n == 1)         return 1;         result = fact(n - 1) * n;         return result;     } }  class Program  {     public static void main(String args[])      {         recursion obj = new recursion() ;         Console.WriteLine(obj.fact(4));     } }

Choices:
- 24
- 30
- 120
- 144


Question:
What will be the output of the following C# code?
 class maths  {     int fact(int n)      {         int result;         if (n == 1)         return 1;         result = fact(n - 1) * n;         return result;     } }  class Output  {     static void main(String args[])      {         maths obj = new maths() ;         Console.WriteLine(obj.fact(1));     } }

Choices:
- 2
- 10
- 1
- 0


Question:
What will be the output of the following C# code snippet?
class maths  {     int fact(int n)      {         int result;         if (n == 1)         return 1;         result = fact(n - 1) * n;         return result;     } }  class Output  {     static void main(String args[])      {         maths obj = new maths() ;         Console.WriteLine(obj.fact(4)*obj.fact(2));     } }

Choices:
- 64
- 60
- 120
- 48


Question:
What will be the output of the following C# code?
 class maths  {     int fact(int n)      {         int result;         if (n == 1)         return 1;         result = fact(n - 1) * n;         return result;     } }  class Output  {     static void main(String args[])      {         maths obj = new maths() ;         Console.WriteLine(obj.fact(4)*(3));     } }

Choices:
- 64
- 60
- 72
- 84


Question:
What will be the output of the following C# code snippet?
 class maths {     public int fact(int n)     {         int result;         result = fact(n - 1) * n;         return result;     } }  class Program {     static void Main(string[] args)     {                     maths obj = new maths();         Console.WriteLine(obj.fact(4));         Console.ReadLine();     } }

Choices:
- 24
- 30
- Compile time error
- Runtime Error


Question:
What will be the output of the following C# code snippet?
 class maths {     public int fact(int n)     {         int result;         if (n == 2)         return 1;         result = fact(n - 1) * n;         return result;     } }  class Program {     static void Main(string[] args)     {                     maths obj = new maths();         Console.WriteLine(obj.fact(4));         Console.ReadLine();     } }

Choices:
- 24
- 0
- 12
- 1


Question:
c)
   class student
   {
       int[,] a = new int[6, 6];
       public int property WriteOnly
       {
           set
           {
               a[i, j] = value;
           }
       }
   }

Choices:
- 8. Choose the correct alternative that utilizes the indexed property such that a group named class has indexed property which stores or retrieves value to/from an array of 5 numbers?
- group[3] = 34;
- group g = group();
- Console.WriteLine(group[3]);


Question:
What will be the output of the following C# code?
 class list {     ArrayList array = new ArrayList();     public object this[int index]     {         get         {             if (index < 0 || index >= array.Count)             {                 return null;             }             else             {                 return (array[index]);             }         }         set         {             array[index] = value;         }     }     public int Count     {         get;        set;     }}class Program{    static void Main(string[] args)    {        list list1 = new list();        list1[0] = "123";        list1[1] = " abc ";        list1[2] = "xyz";        for (int i = 0; i<=list1.Count; i++)        Console.WriteLine(list1[i]);        Console.ReadLine();    }}

Choices:
- Compile time error
- Run time error
- 123, abc, xyz
- 0


Question:
Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the code below to work. Which is the correct solution to ensure this functionality?
b.maths = 10;
Console.WriteLine(b.maths);

Choices:
- Declare maths property with get and set accessors
- Declare maths property with only get accessors
- Declare maths property with only set accessors
- Declare maths property with only get, set and normal accessors


Question:
What will be the output of the following C# code?
  class number  {      private int num1 = 60;      private int num2 = 20;      public int anumber      {          get          {              return num1;          }          set          {              num1 = value;          }      }      public int anumber1      {          get          {              return num2;          }          set          {              num2 = value;          }      }  }  class Program  {      public static void Main(string[] args)      {          number p = new number();          number k = new number();          int m = p.anumber;          int t = k.anumber1;          int r = p.anumber * k.anumber1;          Console.WriteLine("sum = " + r);          Console.ReadLine();      }  }

Choices:
- 0
- 120
- 1200
- Compile time error


Question:
What will be the output of the following C# code?
 class number {     int length = 50;     public int number1     {         get         {             return length;         }         set         {             length = value;         }     } } class Program {     public static void Main(string[] args)     {         number p = new number();         p.number1 = p.number1 + 40;         int k = p.number1 * 3 / 9;         Console.WriteLine(k);         Console.ReadLine();     } }

Choices:
- 0
- 180
- 30
- Compile time error


Question:
What will be the output of the following C# code?
  class number  {      int length = 60;      public int number1      {          get          {              return length;          }      }  }  class Program  {      public static void Main(string[] args)      {          number p = new number();          int l;          l = p.number1 + 40;          int k = l * 3 / 4;          Console.WriteLine(k);          Console.ReadLine();      }  }

Choices:
- 30
- 75
- 80
- 0


Question:
What will be the output of the following C# code?
  class student  {      int []scores = new int[5] {23, 42, 54, 11, 65};      public int this[int index]      {          get          {              if (index < 5)              return scores[index];              else              {                  Console.WriteLine("invalid index");                  return 0;              }          }          set          {              if (index < 5)              scores[index] = value;              else              Console.WriteLine("invalid index");          }      }  }  class Program  {      public static void Main(string[] args)      {          student s = new student();          Console.WriteLine(s[4] + 8);          Console.ReadLine();      }  }

Choices:
- 73
- 37
- 0
- Run time error


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {                 try      {         Console.WriteLine("csharp" + " " + 1/Convert.ToInt32(0));     }     catch(ArithmeticException e)      {         Console.WriteLine("Java");        	     }     Console.ReadLine(); }

Choices:
- csharp
- java
- run time error
- csharp 0


Question:
What will be the output of the following C# code?
  class Program  {      static void Main(string[] args)      {                      try           {              Console.WriteLine("csharp" + " " + 1/0);          }          finally          {              Console.WriteLine("Java");        	          }          Console.ReadLine();      }  }

Choices:
- csharp 0
- Run time Exception generation
- Compile time error
- Java


Question:
What will be the output of the following C# code?
  {      int sum = 10;      try      {          int i;          for (i = -1; i < 3; ++i)          sum = (sum / i);      }      catch (ArithmeticException e)      {          Console.WriteLine("0");      }      Console.WriteLine(sum);      Console.ReadLine();  }

Choices:
- 0
- 0 5
- 0 -10
- Compile time error


Question:
What will be the output of the following C# code?
{    try     {        int []a = {1, 2, 3, 4, 5};        for (int i = 0; i < 5; ++i)         Console.WriteLine(a[i]);        int x = (1 / Convert.ToInt32(0));    }    catch(IndexOutOfRangeException e)     {        Console.WriteLine("A");        	    }    catch(ArithmeticException e)     {     	        Console.WriteLine("B");    }    Console.ReadLine();}

Choices:
- 1234
- 12345
- Run time error
- 12345B


Question:
What will be the output of the following C# code?
{    try     {        int []a = {1, 2, 3, 4, 5};        for (int i = 0; i < 7; ++i)         Console.WriteLine(a[i]);    }    catch(IndexOutOfRangeException e)     {        Console.WriteLine("0");        	    }    Console.ReadLine();}

Choices:
- 12345
- 123450
- 1234500
- Compile time error


Question:
What will be the output of the following C# code snippet?
 {     try      {         int a, b;         b = 0;         a = 10 / b;         Console.WriteLine("A");     }     catch(ArithmeticException e)      {         Console.WriteLine("B");        	     }     Console.ReadLine(); }

Choices:
- A
- B
- Compile time error
- Run time error


Question:
What will be the output of the following C# code?
 {     try      {         int i, sum;         sum = 10;         for (i = -1 ;i < 3 ;++i)          {             sum = (sum / i);             Console.WriteLine(i);         }     }     catch(ArithmeticException e)      {         Console.WriteLine("0");     }     Console.ReadLine(); }

Choices:
- -1
- 0
- -1 0
- -1 0 -1


Question:
What will be the output of the following C# code snippet?
 {     try      {         int a, b;         b = 0;         a = 5 / b;         Console.WriteLine("A");     }     catch(ArithmeticException e)      {         Console.WriteLine("B");     }     finally     {         Console.WriteLine("C");     }     Console.ReadLine(); }

Choices:
- A
- B
- B C
- Run time error


Question:
What will be the output of the following C# code?
 public  static void Main(string[] args) {     try     {         int a, b, c = 5;         b = 0;         a = c / b;         Console.WriteLine("A");     }     catch (ArithmeticException e)     {         int c = 5;         int i = 10;         int z = 2 * c - i;         Console.WriteLine("B");         Console.WriteLine(z);     }     Console.ReadLine(); }

Choices:
- Compile time error
- Run time error
- B 0
- B


Question:
What will be the output of the following C# code snippet?
   class program   {       public static void Main(string[] args)       {           try            {               int a = args.Length;               int b = 1 / a;               Console.WriteLine(a);           }           catch (ArithmeticException e)            {               Console.WriteLine("1");           }           Console.ReadLine();       }   }

Choices:
- 0
- 1
- Compile time error
- Runtime error


Question:
What will be the output of the following C# code snippet?
 class program {     public static void Main(string[] args)     {         try         {             throw new NullReferenceException("C");             Console.WriteLine("A");         }         catch (ArithmeticException e)          {             Console.WriteLine("B");         }         Console.ReadLine();     } }

Choices:
- A
- B
- Compile time error
- Runtime error


Question:
What will be the output of the following C# code snippet?
 class Program {     public static void Main(string[] args)     {         try         {             int a = 1;             int b = 10 / a;             try             {                 if (a == 1)                     a = a / a - a;                 if (a == 2)                 {                     int[] c = { 1 };                     c[8] = 9;                 }             }             finally             {                 Console.WriteLine("A");             }        }        catch (IndexOutOfRangeException e)        {             Console.WriteLine("B");        }        Console.ReadLine();    } }

Choices:
- A
- B
- AB
- BA


Question:
What will be the output of the following C# code snippet?
 class Program {     public static void Main(string[] args)     {         try         {             int a = args.Length;             int b = 10 / a;             Console.WriteLine(a);             try             {                 if (a == 1)                 a = a / a - a;                 if (a == 2)                 {                     int[] c = { 1 };                     c[8] = 9;                 }             }             catch (IndexOutOfRangeException e)             {                 Console.WriteLine("TypeA");             }         }         catch (ArithmeticException e)         {             Console.WriteLine("TypeB");         }         Console.ReadLine();     } }

Choices:
- TypeA
- TypeB
- 0TypeA
- Compile time error


Question:
What will be the output of the following C# code?
 class Output  {     public static void main(String args[])      {          try          {             int a = 9;             int b = 5;             int c = a / b - 5;             Console.WriteLine("Hello");         }         catch(Exception e)          {             Console.WriteLine("C");         }          finally          {             Console.WriteLine("sharp");         }      } }

Choices:
- Hello
- C
- Hellosharp
- Csharp


Question:
What will be the output of the following C# code?
  class Output   {      public static void main(String args[])       {          try           {              int a = 10;              int b = 5;              int c = a / b - 5;              Console.WriteLine("Hi");          }          catch(Exception e)           {              Console.WriteLine("hello");          }       }  }

Choices:
- Hi
- hello
- Hihello
- Compile time error


Question:
What will be the output of the following C# code?
  class Output   {      public static void main(String args[])       {         try          {             int a = 5;             int b = 10;             int c = b / a - 5;             Console.WriteLine("Csharp");         }      } }

Choices:
- Csharp
- sharp
- C
- Compile time error


Question:
What will be the output of the following C# code snippet?
 class Output  {     public static void main(String args[])     {        try         {            int a = 0;            int b = 5;            int c = a / b - 5;            Console.WriteLine("C");        }        finally         {            Console.WriteLine("sharp");        }     }}

Choices:
- C
- sharp
- Csharp
- None of the mentioned


Question:
What will be the output of the following C# code snippet?
 class Output  {     public static void main(String args[])      {         try          {             int a = 10;             int b = 5;             int c =  b - 5 / 5;             Console.WriteLine("Hi");         }         catch(Exception e)          {             Console.WriteLine("hello");         }      } }

Choices:
- Hi
- hello
- Hihello
- Compile time error


Question:
What will be the output of the following C# code?
 static void Main(string[] args) {     Console.WriteLine("This is a Console Application:");     Console.Write("Please enter your lucky number:");     string val1 = Console.ReadLine();     int val2 = System.Convert.ToInt32(val1, 10);     val2 = val2 * val2;     Console.WriteLine("square of number is:" +val2);     Console.Read(); }

Choices:
- Compile time error
- Runs successfully does not print anything
- Runs successfully, ask for input and hence displays the result
- Syntax Error


Question:
What will be the output for following input from the console as a character?
 static void Main(string[] args) {     Console.WriteLine("what is your name?");     char s;     s = Convert.ToChar(Console.ReadLine());     Console.WriteLine("how are you: "+s);     Console.Read(); }

Choices:
- Compile time error
- Code run successfully prints nothing on console
- Code runs successfully prints input on console
- Run time error


Question:
What will be the output of the following C# code snippet?
 static void Main(string[] args) {     String a ="i love iostream";     Console.WriteLine(a.IndexOf('i') + " " + a.IndexOf('e') + " " + a.LastIndexOf('i') + " " + a.LastIndexOf('e'));     Console.ReadLine(); }

Choices:
- 0 6 7 8
- 0 5 7 9
- 5 9 0 7
- 0 5 7 12


Question:
What will be the output of the following C# code snippet?
 static void Main(string[] args) {     StringBuilder sb = new StringBuilder("hello world");     sb.Insert(6, "good");     Console.WriteLine(sb);     Console.ReadLine(); }

Choices:
- hello 6world
- hello good world
- hello goodworld
- hello good world


Question:
What will be the output of the following C# code snippet?
 static void Main(string[] args) {     string h = "i lovelife";     string h1 = new string(h.Reverse().ToArray());     Console.WriteLine(h1);     Console.ReadLine(); }

Choices:
- efil evoli
- lifelove i
- efilevol i
- efil evol i


Question:
In the given constructor declaration for character based file operation what does ‘path’ and ‘bool specifies?
 StreamWriter(string path, bool append)

Choices:
- the name of the file to open
- specifies the full path of file
- if append is true, the file is appended to the end of the existing file
- all of the mentioned


Question:
What will be the output of the following C# code snippet?
{    delegate void A(ref string str);    class sample    {        public static void fun( ref string a)        {            a = a.Substring( 7, a.Length - 7);        }    }    class Program    {        static void Main(string[] args)        {            A str1;            string str = "Test Your C#.net skills";            str1 = sample.fun;            str1(ref str);            Console.WriteLine(str);        }    }}

Choices:
- Test Your
- ur C#.NET
- ur C#.NET Skills
- None of the mentioned


Question:
What will be the output of the following C# code snippet?
{    delegate string F(string str);    class sample    {        public static string fun(string a)        {            return a.Replace(',''-');        }    }    class Program    {        static void Main(string[] args)        {            F str1 = new F(sample.fun);            string str = str1("Test Your c#.NET skills");            Console.WriteLine(str);        }    }}

Choices:
- Test Your
- Test-Your-C#.NET-Skills
- ur C#.NET Skills
- None of the mentioned


Question:
What will be the output of the following C# code?
{ delegate string f(string str); class sample {     public static string fun(string a)     {         return a.Replace('k', 'o');     } } class Program {     static void Main(string[] args)     {         f str1 = new f(sample.fun);         string str = str1("Test Ykur C#.NET Skills");         Console.WriteLine(str);         Console.ReadLine();     } }}

Choices:
- Test Ykur C#.NET Skills
- Test Ykour C#.NET Skills
- Test Your C#.NET Skills
- Test ur C#.NET Skills


Question:
What does the following C# code block defines?
 class Gen<T>  {        T ob;     }

Choices:
- Generics class declaration
- Generic constructor declaration
- A simple class declaration
- All of the mentioned


Question:
What does the following C# code set defines?
 public Gen(T o)  {      ob = o;  }

Choices:
- Generics class Declaration
- Declaration of variable
- Generic constructor declaration
- All of the mentioned


Question:
What will be the output of the following C# code snippet?
public class Generic<T>{    Stack<T> stk = new Stack<T>();    public void push(T obj)    {        stk.Push(obj);    }    public T pop()    {        T obj = stk.Pop();        return obj;    }}class Program{    static void Main(string[] args)    {        Generic<string> g = new Generic<string>();        g.push(40);        Console.WriteLine(g.pop());        Console.ReadLine();    }}

Choices:
- 0
- Runtime Error
- 40
- Compile time Error


Question:
What will be the output of the following C# code snippet?
public class Generic<T>{    Stack<T> stk = new Stack<T>();    public void push(T obj)    {        stk.Push(obj);    }    public T pop()    {        T obj = stk.Pop();        return obj;    }}class Program{    static void Main(string[] args)    {        Generic<int> g = new Generic<int>();        g.push("Csharp");        Console.WriteLine(g.pop());        Console.ReadLine();    }}

Choices:
- Compile time error
- Csharp
- 0
- Run time error


Question:
In the following C# code, which of the following statements are perfectly valid?
public class MyContainer<T> where T: class, IComparable{  /* insert code here */}

Choices:
- Class MyConatiner requires that its type argument must implement Icomparable interface
- There are multiple constraints on type argument to MyConatiner class
- Compiler will report an error
- None of the mentioned


Question:
In the following C# code, which statements are perfectly valid?
public class Csharp{    public void subject<S>(S arg)    {        Console.WriteLine(arg);    }}class Program{    static Void Main(string[] args)    {        Csharp c = new Csharp();        c.subject("hi");        c.subject(20);    }}

Choices:
- Run time exception error
- Compile time error
- Code runs successfully and prints required output
- None of the mentioned


Question:
Which statement is valid for the following C# code snippet?
public class Generic<T>{    public T Field;}class Program{    static void Main(string[] args)    {        Generic<String> g = new Generic<String>();        g.Field = "Hi";        Console.WriteLine(g.Field);    }}

Choices:
- Compile time error
- Generic being a keyword cannot be used as a class name
- Runtime error
- Code runs successfully


Question:
What will be the output of the following C# code?
 public class Generic<T> {     public T Field; } class Program {     static void Main(string[] args)     {         Generic<int> g2 = new Generic<int>();         Generic<int> g3 = new Generic<int>();         g2.Field = 8;         g3.Field = 4;         if (g2.Field % g3.Field == 0)         {             Console.WriteLine("A");         }         else         Console.WriteLine("Prints nothing:");         Console.ReadLine();     } }

Choices:
- Compile time error
- A
- Run time error
- Code runs successfully but prints nothing


Question:
In the following C# code, which of the following statements are perfectly valid?
public class MyContainer<T> where T: IComparable{  /* insert code here */}

Choices:
- Class MyConatiner requires that its type argument must implement Icomparable interface
- There are multiple constraints on type argument to MyContainer class
- Type argument of class MyContainer should be Icomparable
- None of the mentioned


Question:
Which of the following statements are valid in the following C# code snippet?
public class Generic<T>{    public T Field;    public void testSub()    {        T i = Field + 1;    }}class Program{    static void Main(string[] args)    {        Generic<int>g = new Generic<int>();        g.testSub();    }}

Choices:
- code runs successfully but prints nothing
- code runs successfully and prints 1
- program will give run time error
- compile time error


Question:
What will be the output of the following C# code snippet?
public class Generic<T>{    Stack<T> stk = new Stack<T>();    public void push(T obj)    {        stk.Push(obj);    }    public T pop()    {        T obj = stk.Pop();        return obj;    }}class Program{    static void Main(string[] args)    {        Generic<int> g = new Generic<int>();        g.push("Csharp");        Console.WriteLine(g.pop());        Console.ReadLine();    }}

Choices:
- Compile time error
- Csharp
- 0
- Run time error


Question:
What will be the output of the following C# code snippet?
public class Generic<T>{    Stack<T> stk = new Stack<T>();    public void push(T obj)    {        stk.Push(obj);    }    public T pop()    {        T obj = stk.Pop();        return obj;    }}class Program{    static void Main(string[] args)    {        Generic<string> g = new Generic<string>();        g.push(30);        Console.WriteLine(g.pop());        Console.ReadLine();    }}

Choices:
- 0
- 30
- Runtime Error
- Compile time Error


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         int[] nums = { 1, -2, 3, 0, -4, 5};         var posNums = from n in nums                       where n >= 0                       select n;        foreach (int i in posNums)         Console.Write(i + " ");        Console.WriteLine();        Console.ReadLine();    }}

Choices:
- 0, 1, -2, -4, 5
- 1, 3, 0, 5
- 1, 3, 5
- Run time error


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         int[] nums = { 1, -2, 3, 0, -4, 5 };         var posNums = from n in nums                       where n % 2 ==0                       select n;            Console.Write("The positive values in nums: ");            foreach (int i in posNums) Console.Write(i + " ");            Console.WriteLine();            Console.ReadLine();        }    }

Choices:
- code run successfully prints nothing
- run time error
- code run successfully and executes output
- compile time error


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        int[] nums = { 1, -2, 3, 0, -4, 5 };        var posNums = from n in nums                       where n > -5 && n < 6                       orderby n descending                       select n;        Console.Write("The positive values in nums: ");        foreach (int i in posNums) Console.Write(i + " ");        Console.WriteLine();        Console.ReadLine();    }}

Choices:
- Prints nothing code runs successfully
- Run time error
- Arranged in descending order code runs successfully
- Compile time error


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        int[] nums = { 16,  9, 25};        var posNums = from n in nums                      where n > 0                       select Math.Sqrt(n);         Console.Write("The positive values in nums: ");        foreach (int i in posNums) Console.Write(i + " ");        Console.WriteLine();        Console.ReadLine();    }}

Choices:
- Code runs successfully prints nothing
- Code runs successfully prints required output
- Run time error
- Compile time error


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        int[] nums = {1};        var posNums = from n in nums                      wheres n > 0                      select Math.Max(78, 9);        Console.Write("The largest values in nums: ");        foreach (int i in posNums) Console.Write(i + " ");        Console.WriteLine();        Console.ReadLine();    }}

Choices:
- Code runs successfully prints nothing
- Run time error
- Code runs successfully prints required output
- Compile time error


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        string[] strs = {"alpha", "beta", "gamma"};        var chrs = from str in strs                   let chrArray = str.ToCharArray()                   from ch in chrArray                   orderby ch                   select ch;        Console.WriteLine("The individual characters in sorted order:");        foreach (char c in chrs)         Console.Write(c + " ");        Console.WriteLine();        Console.ReadLine();    }}

Choices:
- a a l h a b g m m a p e t a
- a a a a a b e g h l m m p t
- a g h l m m p t a a a a b e
- Run time error


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         int[] nums = { 1, -2, 3, 0, -4, 5 };         var posNums = nums.Where(n => n > 0).Select(r => r*2).                       OrderByDescending(r=>r);         Console.Write("The positive values in nums: ");         foreach(int i in posNums)          Console.Write(i + " ");         Console.WriteLine();         Console.ReadLine();     } }

Choices:
- code run successfully prints nothing
- run time error
- code run successfully prints multiple of 2
- compile time error


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         int[] nums = {3, 1, 2, 5, 4};         var ltAvg = from n in nums                     let x = nums.Average()                     where n < x                     select n;         Console.WriteLine("The average is " + nums.Average());         Console.ReadLine();     } }

Choices:
- Run time error
- 3
- 5
- Compile time error


Question:
In the following C# code, what does the output represent?
class Program{    static void Main(string[] args)    {        int[] nums = { 1, -2, 3, 0, -4, 5 };        var posNums = from n in nums                      where n > 0                      select n;        int len = posNums.Count();        Console.WriteLine(len);        Console.ReadLine();    }}

Choices:
- Execution of code with nothing being printed
- Execution of code with printing all numbers
- Execution of code with counting total numbers greater than zero
- Run time error


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         int[] nums = { 1, -2, 3, 0, -4, 5 };         var posNums = nums.Where(n => n < 10).Select(r => r%3);         Console.Write("The values in nums: ");         foreach (int i in posNums) Console.Write(i + " ");         Console.WriteLine();         Console.ReadLine();     } }

Choices:
- Compile time error
- Run time error
- 1 -2 0 0 -1 2
- 2 -1 0 0 -2 1


Question:
What will be the output of the following C# code snippet?
class Program    {        static void Main(string[] args)        {             int[] nums = { 1, -2, -3, 5 };            var posNums = from n in nums                          orderby n descending                          select n*4 / 2;            Console.Write("The values in nums: ");            foreach (int i in posNums) Console.Write(i + " ");            Console.WriteLine();            Console.ReadLine();        }    }

Choices:
- 10 2 -4 -6
- 5 1 -2 -3
- 1 5 -2 -3
- Run time error


Question:
What does the following property defined in the array class defines in C#?
 public bool IsReadOnly { get; }

Choices:
- a property is read only by nature
- property is true if the array object is read only and false otherwise
- value is false for arrays
- all of the mentioned


Question:
What does the following property define in C#?
public static int BinarySearch<T>(T[] array, int index, int length, T value)

Choices:
- Searches a portion of the array specified by array for the value specified by value
- The search begins at the index specified by index and is restricted to length elements. Returns the index of the first match
- If value is not found, returns a zero value
- All of the mentioned


Question:
What will be the output of the following C# code snippet?
 static void Main()  {     int[] nums = { 1, 2, 3, 4, 5 };     Console.Write("Original order: ");     foreach(int i in nums)     Console.Write(i + " ");     Array.Reverse(nums);     Console.Write("Reversed order: ");     foreach(int i in nums)     Console.Write(i + " ");     Console.WriteLine(); }

Choices:
- Run time error
- 5, 4, 3, 2, 1
- Compile time error
- None of the mentioned


Question:
What does the following C# code signify?
expr is type

Choices:
- Determines the type of an object
- a simple deceleration
- Both Determines the type of an object & a simple deceleration
- None of the mentioned


Question:
What will be the output of the following C# code snippet?
class A {}class B : A {}class CheckCast {    static void Main()     {        A a = new A();        B b = new B();        b = a as B;        b = null;        if(b==null)        Console.WriteLine("The cast in b = (B) a is NOT allowed.");        else        Console.WriteLine("The cast in b = (B) a is allowed");    }}

Choices:
- Run time error
- The cast in b = (B) a is NOT allowed
- The cast in b = (B) a is allowed
- Compile time error


Question:
What does the following declaration specify?
 MethodInfo[] GetMethods()

Choices:
- Returns an array of MethodInfo objects
- Returns a list of the public methods supported by the type by using GetMethods()
- Both Returns an array of MethodInfo objects & Returns a list of the public methods supported by the type by using GetMethods()
- None of the mentioned


Question:
What does the following C# code specify?
object Invoke(object obj, object[] parameters)

Choices:
- Calling a type using invoke()
- Any arguments that need to be passed to the method are specified in the array parameters
- The value returned by the invoked method is returned by Invoke()
- All of the mentioned


Question:
What does the following C# method specify?
  Type[] GetGenericArguments()

Choices:
- A property defined by MemberInfo
- Obtains a list of the type arguments bound to a closed constructed generic type
- The list may contain both type arguments and type parameters
- All of the mentioned


Question:
Which statement is correct in the following C#.NET code snippet?
Stack st = new Stack();st.Push("Csharp");st.Push(7.3);st.Push(8);st.Push('b');st.Push(true);

Choices:
- Unsimilar elements like “Csharp”, 7.3, 8 cannot be stored in the same stack collection
- Boolean values can never be stored in Stack collection
- Perfectly workable code
- All of the mentioned


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         double x = 2.0;           double y = 3.0;         double z = Math.Pow( x, y );         Console.WriteLine(z);         Console.ReadLine();     } }

Choices:
- 2.0
- 4.0
- 8
- 8.0


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         double x = 4.772;         double y = 4.76;         double z = Math.Max(x, y);         Console.WriteLine(z);         Console.ReadLine();     } }

Choices:
- true
- false
- 4.772
- 4.76


Question:
What will be the output of the following C# code snippet?
 public class A {     public int x;     public int y;     public void display()      {         Console.WriteLine(x + " " + y);     } } class Program {     static void Main(string[] args)     {         A obj1 = new A();         A obj2 = new A();         obj1.x = 1;         obj1.y = 2;         obj2 = obj1;         obj1.display();         obj2.display();     } }

Choices:
- 1 2 0 0
- 1 2 1 2
- 0 0 0 0
- Run time exception


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        int[] nums = { 1 };        var posNums = from n in nums                      select Math.Pow(4 ,3);        Console.Write("The values in nums: ");        foreach (int i in posNums)         Console.Write(i + " ");        Console.WriteLine();        Console.ReadLine();    }}

Choices:
- Run time error
- 64
- Compile time error
- 81


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        float x = 3.14F;        int y = (int)Math.Abs(x);        Console.WriteLine(y);        Console.ReadLine();    }}

Choices:
- Compile time error
- 3.14
- 3
- 4


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        int x = 5;        int y = (int)Math.Pow(x,2);        int z = (int)Math.Pow(y, 2);        Console.WriteLine(z);        Console.ReadLine();    }}

Choices:
- 25
- 625
- Compile time error
- Run time error


Question:
What will be the output of the following C# code snippet?
 class Program {     static void Main(string[] args)     {         int[] nums = {3 ,1 ,2 ,5 ,4};         var ltAvg = from n in nums                     let x = nums.Average()                     where n < x                     select n;         Console.WriteLine("The average is " + nums.Average());         Console.ReadLine();     } }

Choices:
- Run time error
- 3
- 5
- Compile time error


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        int y = (int)Math.Max(4,2);        int z = (int)Math.Pow(y, 2);        Console.WriteLine(z);        Console.ReadLine();    }}

Choices:
- 4
- Compile time error
- 16
- 89


Question:
What will be the output of the following C# code snippet?
 public class A {     public int x;     public int y;     public void display()      {         Console.WriteLine(x + " " + y);     } } class Program {     static void Main(string[] args)     {         A obj1 = new A();         A obj2 = new A();         obj1.x = 1;         obj1.y = 2;         obj2 = obj1;         obj1.display();         obj2.display();     } }

Choices:
- 1 2 0 0
- 1 2 1 2
- 0 0 0 0
- Run time exception


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        double x = 3.14;          int y = (int) Math.Abs(x);        Console.WriteLine(y);    }}

Choices:
- 0
- 3
- 3.0
- 3.1


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        double x = 3.14;          int y = (int) Math.Ceiling(x);        Console.WriteLine(y);    }}

Choices:
- 0
- 3
- 3.0
- 4


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        double x = 3.14;          int y = (int) Math.Floor(x);        Console.WriteLine(y);    }}

Choices:
- 0
- 3
- 3.0
- 4


Question:
What does the following C# code snippet specify?
public Thread(ThreadStart start)

Choices:
- Defines a thread
- Declaration of a thread constructor
- Only Defines a thread
- Only Defines a thread & Declaration of a thread constructor


Question:
What will be the output of the following C# code snippet?
 class MyClass {     char[] chrs = { 'A', 'B', 'C', 'D' };     public System.Collections.IEnumerator GetEnumerator()     {         foreach (char ch in chrs)         yield return ch;     } } class Program {     static void Main(string[] args)     {         MyClass mc = new MyClass();         foreach (char ch in mc)         Console.Write(ch + " ");         Console.WriteLine();         Console.ReadLine();     } }

Choices:
- Run time error
- Compile time error
- Code runs successfully prints nothing
- Code runs successfully prints A, B, C, D


Question:
Choose the correct statements for the following C# code?
 public System.Collections.IEnumerator GetEnumerator() {     foreach (char ch in chrs)     yield return ch; }

Choices:
- Definition of iterator for MyClass
- Implements the GetEnumerator() method defined by IEnumerable
- The yield return statement returns the next object in the collection, which in this case is the next character in chrs
- All of the mentioned


Question:
What does the yield return statement specify in the following C# code snippet?
 public System.Collections.IEnumerator GetEnumerator() {     foreach (char ch in chrs)     yield return ch; }a) returns the outputb) returns the next object in the collectionc) Both returns the output & returns the next object in the collectiond) none of the mentioned[expand title="View Answer"] Answer:  bExplanation: The yield return statement returns the next object in the collection, which in this case is the next character in chrs in the code.[/expand] 5. What does the following C# code snippet specify?<pre lang="csharp" line="1" cssfile="hk1_style">class MyClass{    char chrs = 'A' ;    public IEnumerator GetEnumerator()    {        for (int i = 20; i >=0; --i)        yield return (char)((chrs + i));    }}class Program{    static void Main(string[] args)    {        MyClass mc = new MyClass();        foreach (char ch in mc)        Console.Write(ch + " ");        Console.WriteLine();        Console.ReadLine();    }}

Choices:
- A B C D E F G H I J K L M N O P Q R S T U V
- Run time error
- U T S R Q P O N M L K J I H G F E D C B A
- Compile successfully prints nothing


Question:
What will be the following C# code snippet specify?
class MyClass{    char chrs = 'A' ;    public IEnumerator GetEnumerator()    {        for (int i = 20; i >=0; --i)        if (i == 10) yield break;        yield return (char)((chrs + i));    }}class Program{    static void Main(string[] args)    {        MyClass mc = new MyClass();        foreach (char ch in mc)        Console.Write(ch + " ");        Console.WriteLine();        Console.ReadLine();    }}

Choices:
- Code run successfully prints nothing
- A B C D E F G H I J K L M N O P Q R S T U V
- U T S R Q P O N M L
- Compile time error


Question:
What will be the output of the following C# code snippet?
 class MyClass {     int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};     public IEnumerator GetEnumerator()     {         for (int i = 0; i < 20; i++)         {             if (a[i] % 2 == 0)             yield return (int)(a[i]);         }     } } class Program {     static void Main(string[] args)     {         MyClass mc = new MyClass();         foreach (int i in mc)         Console.Write(i + " ");         Console.WriteLine();         Console.ReadLine();     } }

Choices:
- prints nothing code run successfully
- run time error
- code runs successfully prints even number between 1 to 20
- compile time error


Question:
What will be the output of the following C# code snippet?
class MyClass{    char ch = 'A';    int e = 4;    int k = 9;    int z = 6;    public IEnumerator GetEnumerator()    {        for (int i = 0; i < 26; i++)        {            if (i == e*k /z) yield break;             yield return (int)(ch + i);        }    }}class Program{    static void Main(string[] args)    {        MyClass mc = new MyClass();        foreach(int ch in mc)        Console.Write(ch + " ");        Console.WriteLine();        Console.ReadLine();    }}

Choices:
- Compile time error
- Run time error
- 65 66 67 68 69 70
- Code run successfully prints nothing


Question:
What will be the output of the following C# code?
class box {    int width;    int height;    int length;    int volume;    void volume(int height, int length, int width)     {        volume = width * height * length;    } }    class Prameterized_method{    public static void main(String args[])     {       box obj = new box();       obj.height = 1;       obj.length = 5;       obj.width = 5;       obj.volume(3, 2, 1);       Console.WriteLine(obj.volume);         Console.ReadLine();          } }

Choices:
- 0
- 1
- 6
- 25


Question:
What will be the output of the following C# code snippet?
class equality {    int x;    int y;    boolean isequal()    {        return(x == y);      } }    class Output {    public static void main(String args[])     {       equality obj = new equality();       obj.x = 5;       obj.y = 5;       Console.WriteLine(obj.isequal());    } }

Choices:
- false
- true
- 0
- 1


Question:
What will be the output of the following C# code snippet?
 class equality {     public  int x;     public int y;     public Boolean isequal()     {         return (x == y);     } }     class Program {     static void Main(string[] args)     {         equality obj = new equality();         obj.x = 5;         obj.y = 5;         Console.WriteLine(obj.isequal());         Console.ReadLine();     } }

Choices:
- false
- true
- 0
- 1


Question:
What will be the output of the following C# code snippet?
class box{    public  int width;    public int height;    public int length;    public  int volume1;    public void volume()    {        volume1 = width * height * length;    }    public void volume(int x)    {        volume1 = x;    }}    class Program{    static void Main(string[] args)    {        box obj = new box();        obj.height = 1;        obj.length = 5;        obj.width = 5;        obj.volume(5);        Console.WriteLine(obj.volume1);                Console.ReadLine();    }}

Choices:
- 0
- 5
- 25
- 26


Question:
What will be the output of the following C# code snippet?
class Program{    static void Main(string[] args)    {        int x, y = 1;        x = 10;        if(x != 10 && x / Convert.ToInt32(0) == 0)        Console.WriteLine(y);        else        Console.WriteLine(++y);        Console.ReadLine();    }}

Choices:
- 1
- 2
- Run time error
- Compile time error


Question:
What does the following form define?
  Protocol://HostName/FilePath?Query

Choices:
- Protocol specifies the protocol being used, such as HTTP
- HostName identifies a specific server, such as mhprofessional.com or www.google.com
- FilePath specifies the path to a specific file
- All of the mentioned


Question:
What does the following method specify?
   public static WebRequest Create(string requestUriString)

Choices:
- Creates a WebRequest object for the URI specified by the string passed by requestUriString
- The object returned will implement the protocol specified by the prefix of the URI
- The object will be an instance of the class that inherits WebRequest
- All of the mentioned


Question:
What will be the output of the following C# code?
  class Program  {      static void Main(string[] args)      {          int ch;          HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://www.McGraw-Hill.com");          HttpWebResponse resp = (HttpWebResponse) req.GetResponse();          Stream istrm = resp.GetResponseStream();          for (int i = 1 ;  ;i++)          {              ch = istrm.ReadByte();              if (ch == -1)               break;              Console.Write((char)ch);              if ((i % 400) == 0)              {                  Console.Write("\nPress Enter.");                  Console.ReadLine();              }          }          resp.Close();      }  }

Choices:
- html
- text
- html/text
- text/html


Question:
What will be the output of the following C# code?
 class Program {     static void Main(string[] args)      {         Uri obj = new Uri("https://www.sanfoundry.com/csharpmcq");         Console.WriteLine(obj.AbsoluteUri);         Console.ReadLine();     } }

Choices:
- sanfoundry
- sanfoundry.com


Question:
What will be the output of the following C# code snippet?
public class Generic<T>{    Stack<T> stk = new Stack<T>();    public void push(T obj)    {        stk.Push(obj);    }    public T pop()    {        T obj = stk.Pop();        return obj;    }}class Program{    static void Main(string[] args)    {        Generic<int> g = new Generic<int>();        g.push("Csharp");        Console.WriteLine(g.pop());        Console.ReadLine();    }}

Choices:
- Compile time error
- Csharp
- 0
- Run time error


Question:
What will be the output of the following C# code snippet?
public class Generic<T>{    Stack<T> stk = new Stack<T>();    public void push(T obj)    {        stk.Push(obj);    }    public T pop()    {        T obj = stk.Pop();        return obj;    }}class Program{    static void Main(string[] args)    {        Generic<string> g = new Generic<string>();        g.push(30);        Console.WriteLine(g.pop());        Console.ReadLine();    }}

Choices:
- 0
- 30
- Runtime Error
- Compile time Error


Question:
What does the following C# code block define?
 class Gen<T> {                    T ob;                  }

Choices:
- Generics class declaration
- Declaration of variable
- A simple class declaration
- Both Generics class declaration & Declaration of variable


Question:
What does the following C# code set defines?
 public Gen(T o) {                     ob = o;                  }

Choices:
- Generics class decleration
- Decleration of variable
- Generic constructor decleration
- All of the mentioned


Question:
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);    }}

Choices:
- 6
- print garbage value
- print -6
- print address of b + a


Question:
What will be the output of the following C# code segment?
class UnsafeCode{    unsafe static void Main()    {         int n = 10;         void* p = &n;         Console.WriteLine(*p);         Console.ReadLine();     } }

Choices:
- The program will print 10
- Run time error
- Compile time error
- Output is the address contained in p


Question:
What will be the output of the following C# code snippet?
class UnsafeCode{    unsafe static void Main()    {        int* a;        int a1 = 10;        int b1;        b1 = *&a1;        a = &b1;        {            Console.WriteLine(*a);            Console.ReadLine();        }    }}

Choices:
- program will print garbage value
- program will print address of a
- program will print value of a1
- program will print address of a1


Question:
What will be the output of the following C# code snippet?
class UnsafeCode{    unsafe static void Main()    {        int n = 10;        int* p = &n;        int** p1 = &p;        int*** p2 = &p1;        Console.WriteLine(*p * **p1 * ***p2);        Console.ReadLine();    }}

Choices:
- compile time error
- garbage value is printed
- program will print 1000
- program will print 100


Question:
What will be the output of the following C# code snippet?
class UnsafeCode{    unsafe static void Main()    {            int* p;            p = (int*)(65535);            Console.WriteLine((uint)p);            Console.ReadLine();    }}

Choices:
- compile time error
- garbage value
- program prints value at address 65535
- program prints 65535


Question:
What will be the output of the following C# code snippet?
 class UnsafeCode {     unsafe static void Main()     {         int m = 10;         int *mptr = &m;         int **ptr = &mptr;         int n = 20;         int *nptr = &n;         int **prt = &nptr;         m = **prt + *nptr;         n = *mptr* **prt;         Console.WriteLine(n + " " + m);         Console.ReadLine();     } }

Choices:
- 20 200
- 40 200
- 800 40
- 40 800


Question:
What will be the output of the following C# code snippet?
 unsafe static void Main() {     int a = 5;     int b = 5;     int c = 5;     int*[] ptr = new int* [3];     ptr[0] = &a;     ptr[1] = &b;     ptr[2] = &c;     for (a = 0; a < 3; a++)     {         c += *ptr[a];         Console.WriteLine(c);     }     Console.ReadLine(); }

Choices:
- 5 10
- 10 20
- Compile time error
- 5 10 20


Question:
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)        {            ptrs[i] = ptrs[i]* 3;            ptrs[i] = ptrs[i] + 4;            Console.WriteLine(ptrs[i]);        }        Console.ReadLine();    }}

Choices:
- 20, 10, 7
- 13, 10, 7
- 6, 9, 3
- Compile time error


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

Choices:
- ACCEE
- FBCDE
- BBDDF
- BBCEE


Question:
What will be the output of the following C# code snippet?
class UnsafeCode {     unsafe static void Main()     {          int[] nums = new int[10];         Console.WriteLine("Index pointer like array.");         fixed (int* p = nums)         {             for (int i = 0 ;i <10 ;i++)             p[i] = i;             for (int i = 10 ;i >0 ;i--)             Console.WriteLine("p[{0}]: {1} ", i, p[i]);             Console.ReadLine();         }     } }

Choices:
- p[10] :0, p[9] :9, p[8] :8…..p[1]:1
- p[10] : 1, p[9] :2, p[8] :3…..p[1] :0
- p[1] : 1, p[2] :2, p[3] :3…..p[10] :0
- Compile time error


Question:
What will be the output of the following C# code snippet?
 class UnsafeCode {     unsafe static void Main()     {         string str = "this is a test";              fixed (char* p = str)            {                for (int i = str.Length-1 ;p[i] != 0 ;i--)                Console.Write(p[i]);            }        Console.ReadLine();    } }

Choices:
- test a is this
- compile time error
- tset a si siht
- run time error


Question:
What will be the output of the following C# code snippet?
 class UnsafeCode {     unsafe static void Main()     {         int* p ;         int ch = 13*5;         p = &(ch);         Console.WriteLine(Convert.ToChar(*p));         if (*p == 'A')         Console.WriteLine(Convert.ToBoolean(1));         else         Console.WriteLine(Convert.ToBoolean(0));         Console.ReadLine();     } }

Choices:
- 65 False
- 65 1
- A True
- A 1


Question:
What will be the output of the following C# code snippet?
class UnsafeCode{    struct MyStruct    {        public int a;        public int b;        public int Sum()        {            return a * b;        }   }   unsafe static void Main()   {       MyStruct o = new MyStruct();       MyStruct* p;        p = &o;       p->a = 10;        p->b = 20;        Console.WriteLine("Value is " + p->Sum());       Console.ReadLine();   }}

Choices:
- Compile time error
- Run time error
- 200
- 30


Question:
What will be the output of the following C# code snippet?
class UnsafeCode{    struct MyStruct    {        public int a;        public int b;        public int Sum()        {            return a / b;        }   }   unsafe static void Main()   {       MyStruct o = new MyStruct();       MyStruct* p;        p = &o;       p->a = 60;        p->b = 15;        int c = 30;       Console.WriteLine("Value is : " + p->Sum()*c);       Console.ReadLine();   }}

Choices:
- Compile time error
- 120
- Run time error
- 4


Question:
What will be the output of the following C# code snippet?
class UnsafeCode{    unsafe static void Main()    {        int[] nums = new int[10];        fixed (int* p = &nums[0], p2 = nums)        {            if (p == p2)            Console.WriteLine("p and p2 point to same address.");            Console.ReadLine();        }    }}

Choices:
- Run time error
- Compile time error
- p and p2 point to the same address
- Only p2


Question:
What will be the output of the following C# code snippet?
class UnsafeCode{    static void Main()    {        int? count = null;        int? result = null;        int incr = 10;        result = count + incr;        if (result.HasValue)            Console.WriteLine("result has this value: " + result.Value);        else            Console.WriteLine("result has no value");        Console.ReadLine();    }}

Choices:
- Run time error
- 0
- Result has no value
- Compile time error


Question:
What will be the output of the following C# code snippet?
class UnsafeCode{    static void Main()    {        int count = 100;        int? result = null;        int incr = 10;        result = count + incr;        if (result.HasValue)            Console.WriteLine("result has this value: " + result.Value);        else            Console.WriteLine("result has no value");        Console.ReadLine();    }}

Choices:
- Run time error
- 110
- Result has no value
- Compile time error


Question:
What will be the output of the following C# code snippet?
 unsafe struct FixedBankRecord {     public fixed byte Name[80];      public double Balance;     public long ID; } class UnsafeCode {     unsafe static void Main()     {         Console.WriteLine("Size of FixedBankRecord is " + sizeof(FixedBankRecord));         Console.ReadLine();     } }

Choices:
- Run time error
- 80
- 96
- Compile time error


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

Choices:
- 3 2 1
- 1 2 3
- None of the mentioned
- Run time error


Question:
What will be the output of the following C# code snippet?
 class access {     public int x;     private int y;     public  void cal(int a, int b)     {         x = a + 1;         y = b;     } }     class Program {     static void Main(string[] args)     {         access obj = new access();            obj.cal(2, 3);         Console.WriteLine(obj.x + " " + obj.y);          } }

Choices:
- 3 3
- 2 3
- Run time error
- Compile time error


Question:
What will be the output of the following C# code snippet?
class access{    public int x;    private int y;    public  void cal(int a, int b)    {        x = a + 1;        y = b;    }    public  void print()    {       Console.WriteLine(" " + y);        } }    class Program{    static void Main(string[] args)    {        access obj = new access();           obj.cal(2, 3);        Console.WriteLine(obj.x);        obj.print();        Console.ReadLine();    }}

Choices:
- 2 3
- 3 3
- Run time error
- Compile time error


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

Choices:
- 6, 9
- 5, 9
- 9, 10
- 3, 2


Question:
What will be the output of the following C# code snippet?
class static_out{    public static int x;    public  static int y;    public int add(int a, int b)    {        x = a + b;        y = x + b;        return 0;    }}    class Program{    static void Main(string[] args)    {        static_out obj1 = new static_out();        static_out obj2 = new static_out();           int a = 2;        obj1.add(a, a + 1);        obj2.add(5, a);        Console.WriteLine(static_out.x + " " + static_out.y );             Console.ReadLine();    }}

Choices:
- 7 7
- 6 6
- 7 9
- 9 7