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 445
Correct 138
Incorrect 134
Viewed 173

Answers

Guest
Guest
Shamsa hafeez
Shamsa hafeez - 5 days ago

Shamsa hafeez from Lahore, Pakistan is saying 2 is correct answer

Rakhi Sharma
Rakhi Sharma - 2 weeks ago

Rakhi Sharma is saying Compilation Error: Incorrect Syntax is correct answer

nikunj jhala
nikunj jhala - 2 weeks ago

nikunj jhala from Mumbai, India is saying Compilation Error: Incorrect Syntax is correct answer

Vaibhav Bisht
Vaibhav Bisht - 1 month ago

Vaibhav Bisht from Dehradun, India is saying Compilation Error: size of array must be defined is correct answer

Zo Go
Zo Go - 1 month ago

Zo Go 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

Arrays in Java are implemented as?

  • [A] class
  • [B] object
  • [C] variable
  • [D] None of the mentioned