5 years ago in Java Arrays

What will happen when following Java code block is compiled and run?

public class A {

public static void main(String argv[]){

int ary[]=new int[]{1,2,3};

System.out.println(ary[1]);

}

}

[A] 1
[B] Compilation Error: Incorrect Syntax
[C] 2
[D] Compilation Error: size of array must be defined
Loading...
Next Question

Overall Stats

Attempted 219
Correct 115
Incorrect 35
Viewed 69

Answers

Guest
Guest
Vaibhav Bisht
Vaibhav Bisht - 4 weeks ago

Vaibhav Bisht from Dehradun, India is saying 1 is correct answer

Fâtïmá Żahřâ Zágñane
Fâtïmá Żahřâ Zágñane - 1 month ago

Fâtïmá Żahřâ Zágñane from Casablanca, Morocco is saying 2 is correct answer

Awa Kone
Awa Kone - 1 month ago

Awa Kone from Berrechid, Morocco is saying 2 is correct answer

ayoub benigmim
ayoub benigmim - 1 month ago

ayoub benigmim from Casablanca, Morocco is saying 2 is correct answer

AHMED SOULIMANI
AHMED SOULIMANI - 1 month ago

AHMED SOULIMANI from Casablanca, Morocco is saying 2 is correct answer

Related Questions

Which of these is necessary to specify at time of array initialization?

  • [A] Row
  • [B] Column
  • [C] Both Row and Column
  • [D] None of the mentioned