What will be the output of the following C# code? | Question 7

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

using System;

class Program {
  static void Main(string[] args) {
    int i = 2;
    int j = 10 / 4;

    if (i == j) {
      Console.WriteLine("True");
    } else {
      Console.WriteLine("False");
    }
  }
}
  1. True
  2. False
  3. Error
  4. None

Answer: A) True

Explanation:

The statement int j = 10/4; The value of j will be 2 because of implicit type casting. Thus, the output will be "True".

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.