C# Questions & Answers on Rounding Functions for Freshers

1. Which among the given classes provides types of rounding functions?

a) Math
b) Process
c) System
d) Object
Answer: a
2. Which of these methods is a rounding function of Math class?

a) Max()
b) Min()
c) Abs()
d) Round()
Answer: d

Explanation: Round() rounds up a variable to nearest integer
3. Which of these classes contains only floating point functions?

a) Math
b) Process
c) System
d) Object
Answer: a

Explanation: Math class contains all the floating point functions that are used for general purpose mathematics methods. Example : sin(), cos(), exp(), sqrt() etc.
4. Which of these method returns a smallest whole number greater than or equal to variable X?

a) double Ciel(double X)
b) double Floor(double X)
c) double Max(double X)
d) double Min(double X)
Answer: a

Explanation: Ciel(double X) returns the smallest whole number greater than or equal to variable X.
5. Which of these methods return a largest whole number less than or equal to variable X?

a) double Ciel(double X)
b) double Floor(double X)
c) double Max(double X)
d) double Min(double X)
Answer: b

Explanation: double Floor(double X) returns a largest whole number less than or equal to variable X.
6. Which of the following functions return absolute value of a variable?

a) Abs()
b) Absolute()
c) absolutevariable()
d) None of the mentioned
Answer: a

Explanation: Abs() returns the absolute value of a variable
7. What will be the output of the given 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
Output: 1 2 1 2
8. What will be the output of the given code snippet?
  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         double x = 3.14;  
  6.         int y = (int) Math.Abs(x);
  7.         Console.WriteLine(y);
  8.     }
  9. }
a) 0
b) 3
c) 3.0
d) 3.1
Answer: b
Output: 3
9. What will be the output of the given code snippet?
  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         double x = 3.14;  
  6.         int y = (int) Math.Ceiling(x);
  7.         Console.WriteLine(y);
  8.     }
  9. }
a) 0
b) 3
c) 3.0
d) 4
Answer: d

Explanation: Ceiling(double x) returns the smallest whole number greater than or equal to variable x.
Output: 4
10. What will be the output of the given code snippet?
  1. class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         double x = 3.14;  
  6.         int y = (int) Math.Floor(x);
  7.         Console.WriteLine(y);
  8.     }
  9. }
a) 0
b) 3
c) 3.0
d) 4
Answer: b

Explanation: double Floor(double X) returns the largest whole number less than or equal to variable X. Here, the smallest whole number less than 3.14 is 3.
Output: 3

Related

Computer Fundamentals Multiple choice Questions and Answers on Multithreading for Freshers

1. Multithreading is also called as ____________ a) Concurrencyb) Simultaneityc) Crosscurrentd) Recurrent Answer: a Explanation: Concurrency is often used in place of multithreading. Multitasking...

Computer Fundamentals Multiple choice Questions and Answers on Multiprogramming for Freshers

1. A __________is a set of instructions which is prepared to perform a specific assignment if executed by a computer. a) Browserb) Internetc) Programd) Code Answer: c Explanation: A set of meanin...

Computer Fundamentals Multiple choice Questions and Answers on Program Errors for Freshers

1. ______________ is done in the development phase by the developers. a) Deploymentb) Debuggingc) Verificationd) Validation Answer: b Explanation: Debugging is done in the development phase by th...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item