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

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

using System;

namespace MyApplication {
  class Program {
    static void Main(string[] args) {
      string[] mobiles = {"iPhone", "Samsung", "Vivo"};
      Console.WriteLine(mobiles[0] + mobiles[2]);
    }
  }
}
  1. iPhoneVivo
  2. iPhone+Vivo
  3. Exception
  4. iPhone Vivo

Answer: A) iPhoneVivo

Explanation:

In the above code, the statement mobiles[0]+mobiles[2] will concatenate the 0th and 2nd elements that are "iPhone" and "Vivo". Thus, the output will be "iPhoneVivo".

Comments and Discussions!

Load comments ↻






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