Professional Documents
Culture Documents
ans: c
25-what would be the result of attempting to compile and run the following code?
public Class helloworld{
public static void main(String[] args){
double[] x = new double[]{1, 2, 3};
system.out.println("value is " + x[1]);
}
}
a.the program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it
should be replaced by {1, 2, 3}.
b.the program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it
should be replaced by new double[3]{1, 2, 3};
c.the program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it
should be replaced by new double[]{1.0, 2.0, 3.0};
d.the program compiles and runs fine and the output is 2.0;
ans: d