Question: What is the output of the following code: Java C# class Main { public static void main(String[] args) { int[] myArray =
What is the output of the following code:
| Java | C# |
class Main { public static void main(String[] args) { int[] myArray = new int[5]; try { for(int i=0;i<=5;i++) { myArray[i]=i; } System.out.println(myArray[3]); } catch(Exception e) { System.out.println("Something went wrong"); } } } | using System; class MainClass { public static void Main (string[] args) { int[] myArray = new int[5]; try { for(int i=0;i<=5;i++) { myArray[i]=i; } Console.WriteLine(myArray[3]); } catch(Exception e) { Console.WriteLine("Something went wrong"); } } } |
Step by Step Solution
3.41 Rating (160 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
