Home / CSE MCQs / C#.Net MCQs :: Discussion

Discussion :: C#.Net MCQs

  1. What is the output for the following code ?

    static void Main(string[] args)
      {  
          int a = 5;
          if (Convert.ToBoolean((.002f) -(0.1f)))
          Console.WriteLine("Sachin Tendulkar");
          else if (a == 5)
          Console.WriteLine("Rahul Dravid");
          else
          Console.WriteLine("Ms Dhoni");
          Console.ReadLine();
      }
  2. A.
    Rahul Dravid
    B.
    Sachin Tendulkar
    C.
    Ms Dhoni
    D.
    Warning : Unreachable Code

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    (0.002 “ 0.1f) not equivalent to zero hence it is true. So,only first if clause will execute and print:Sachin Tendulkar on console.As,first condition is always true so no else if statement will be executed. Output: Sachin Tendulkar


Be The First To Comment