My Report

C# Programming Mock Test 2


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

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

 static void Main(string[] args)
 {
     int y = 5;
     int x;
     int k = (!(Convert.ToInt32(y) > 10))?  x = y + 3 : x = y + 10;
     Console.WriteLine(x);
     Console.WriteLine(y);
     Console.ReadLine();
 }

Question 1 of 10

Question 2 of 10

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

 static void Main(string[] args)
 {
     int x = 0;  
     while (x < 20)
     {
         while (x < 10)
         {
             if (x % 2 == 0)
             {
                 Console.WriteLine(x);
             }
             x++;
         }
     }
     Console.ReadLine();
 }

Question 2 of 10

Question 3 of 10

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

   static void Main(string[] args)
   {
       int i = 10 , j = 0;
       label:
       i--;
       if ( i > 0)
       {
           Console.WriteLine(i+ " ");
           goto label;
       }
       Console.ReadLine();
   }
 

Question 3 of 10

Question 4 of 10

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

 static void Main(string[] args)
 {
     int i;
     int b = 8, a = 32;
     for (i = 0; i <= 10; i++)
     {
         if ((a / b * 2)== 2)
         {
             Console.WriteLine( i + " ");
             continue;
         }
         else if (i != 4)
             Console.Write(i + " ");
         else
             break;
    }
    Console.ReadLine();
 }
 

Question 4 of 10

Question 5 of 10

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

 
  static void Main(string[] args)
  {
      int i = 5;
      for (; Convert.ToBoolean(Convert.ToInt32(i)); Console.WriteLine(i--)) ;
      Console.ReadLine();
  }

Question 5 of 10

Question 6 of 10

6. Which among the following is a conditional operator?

Question 6 of 10

Question 7 of 10

7. What is the most specified using class declaration?

Question 7 of 10

Question 8 of 10

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

    static void Main(string[] args)
    {
        Console.WriteLine("HI");
        continue;
        Console.WriteLine("Hello");
        Console.ReadLine();
    }
 

Question 8 of 10

Question 9 of 10

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

  static void Main(string[] args)
  {
      int i = 2, j = 4;
      switch (i + j * 2)
      {
      case 1 :
      case 2 :
          Console.WriteLine("1 and 2");
          break;
      case 3 to 10:
          Console.WriteLine("3 to 10");
          break;
      }
      Console.ReadLine();
  }

Question 9 of 10

Question 10 of 10

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

 static void Main(string[] args)
 {
     int i;
     Console.WriteLine("enter value of i:");
     i = Convert.ToInt32(Console.ReadLine());
     if ( i % 2 == 0)
         goto even:
     else
     {
         Console.WriteLine("number is odd:");
         Console.ReadLine();
     }
     even:
     Console.WriteLine("number is even:");
     Console.ReadLine();
 }
for i = 4.

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.