6 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

Create your Digital Resume For FREE on your name's sub domain "yourname.wcard.io". Register Here!


Overall Stats

Attempted 196
Correct 61
Incorrect 53
Viewed 82

Answers

Guest
Guest
lahari
lahari - 4 years ago

lahari from Chennai, India is saying 2 is correct answer

Mina Atef
Mina Atef - 4 years ago

Mina Atef from Cairo, Egypt is saying 2 is correct answer

Kuheli Mitra
Kuheli Mitra - 4 years ago

Kuheli Mitra from Bangalore, India is saying 2 is correct answer

SHAHEEN -
SHAHEEN - - 4 years ago

SHAHEEN - from Brampton, Canada is saying Compilation Error: Incorrect Syntax is correct answer

Dimana Ignatova
Dimana Ignatova - 4 years ago

Dimana Ignatova from Sofia, Bulgaria is saying Compilation Error: Incorrect Syntax is correct answer

Related Questions