250+ TOP MCQs on Maths Class and Answers

C# MCQs on maths class in C# Programming Language.

1. Which of these classes contains only floating point functions?
a) Math
b) Process
c) System
d) Object

Answer: a
Clarification: Math class contains all the floating point functions that are used for geometry, trigonometry, as well as several general purpose methods. Example : sin(), cos(), exp(), sqrt() etc.

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

  1.  class Program
  2.  {
  3.      static void Main(string[] args)
  4.      {
  5.          double x = 2.0;
  6.          double y = 3.0;
  7.          double z = Math.Pow( x, y );
  8.          Console.WriteLine(z);
  9.          Console.ReadLine();
  10.      }
  11.  }

a) 2.0
b) 4.0
c) 8
d) 8.0

Answer: c
Clarification: None.
Output :

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

  1.  class Program
  2.  {
  3.      static void Main(string[] args)
  4.      {
  5.          double x = 4.772;
  6.          double y = 4.76;
  7.          double z = Math.Max(x, y);
  8.          Console.WriteLine(z);
  9.          Console.ReadLine();
  10.      }
  11.  }

a) true
b) false
c) 4.772
d) 4.76

Answer: c
Clarification: None.
Output :

4. What is the value of double consonant ā€˜Eā€™ defined in Math class?
a) approximately 3
b) approximately 3.14
c) approximately 2.72
d) approximately 0

Answer: c
Clarification: None.

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

  1.  public class A
  2.  {
  3.      public int x;
  4.      public int y;
  5.      public void display()
  6.      {
  7.          Console.WriteLine(x + " " + y);
  8.      }
  9.  }
  10.  class Program
  11.  {
  12.      static void Main(string[] args)
  13.      {
  14.          A obj1 = new A();
  15.          A obj2 = new A();
  16.          obj1.x = 1;
  17.          obj1.y = 2;
  18.          obj2 = obj1;
  19.          obj1.display();
  20.          obj2.display();
  21.      }
  22.  }

a) 1 2 0 0
b) 1 2 1 2
c) 0 0 0 0
d) Run time exception

Answer: b
Clarification: None.
Output :

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

  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         int[] nums = { 1 };
  6.         var posNums = from n in nums
  7.                       select Math.Pow(4 ,3);
  8.         Console.Write("The values in nums: ");
  9.         foreach (int i in posNums)
  10.         Console.Write(i + " ");
  11.         Console.WriteLine();
  12.         Console.ReadLine();
  13.     }
  14. }

a) Run time error
b) 64
c) Compile time error
d) 81

Answer: b
Clarification: None.
Output :

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

  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         float x = 3.14F;
  6.         int y = (int)Math.Abs(x);
  7.         Console.WriteLine(y);
  8.         Console.ReadLine();
  9.     }
  10. }

a) Compile time error
b) 3.14
c) 3
d) 4

Answer: c
Clarification: None.
Output :

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

  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         int x = 5;
  6.         int y = (int)Math.Pow(x,2);
  7.         int z = (int)Math.Pow(y, 2);
  8.         Console.WriteLine(z);
  9.         Console.ReadLine();
  10.     }
  11. }

a) 25
b) 625
c) Compile time error
d) Run time error

Answer: b
Clarification: y = 25, z = 25*25 = 625
Output :

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

  1.  class Program
  2.  {
  3.      static void Main(string[] args)
  4.      {
  5.          int[] nums = {3 ,1 ,2 ,5 ,4};
  6.          var ltAvg = from n in nums
  7.                      let x = nums.Average()
  8.                      where n < x
  9.                      select n;
  10.          Console.WriteLine("The average is " + nums.Average());
  11.          Console.ReadLine();
  12.      }
  13.  }

a) Run time error
b) 3
c) 5
d) Compile time error

Answer: b
Clarification: Built in method of maths class Avg() id used
Output :

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

  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         int y = (int)Math.Max(4,2);
  6.         int z = (int)Math.Pow(y, 2);
  7.         Console.WriteLine(z);
  8.         Console.ReadLine();
  9.     }
  10. }

a) 4
b) Compile time error
c) 16
d) 89

Answer: c
Clarification: Built in method of maths class, Max() is used to select maximum value among 4 and 2 and then y is squared using Pow() of math class and the value is stored in z.
Output :

Leave a Reply

Your email address will not be published. Required fields are marked *