Top Posters
Since Sunday
w
5
a
3
j
2
a
2
t
2
u
2
r
2
j
2
j
2
l
2
d
2
y
2
New Topic  
Dymondmonae Dymondmonae
wrote...
Posts: 489
Rep: 9 0
4 years ago
What would be the result of attempting to compile and run the following code?
 
public class Test {
public static void main(String[] args) {
double[] x = new double[]{1, 2, 3};
System.out.println("Value is " + x[1]);
}
}


▸ 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};

▸ The program compiles and runs fine and the output "Value is 1.0" is printed.

▸ 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};

▸ The program compiles and runs fine and the output "Value is 2.0" is printed.

▸ 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}.
Textbook 
Introduction to Java Programming, Comprehensive Version

Introduction to Java Programming, Comprehensive Version


Edition: 10th
Author:
Read 62 times
1 Reply
Replies
Answer verified by a subject expert
jfinn1021jfinn1021
wrote...
Posts: 388
4 years ago
Sign in or Sign up in seconds to unlock everything for free
More solutions for this book are available here
1

Related Topics

Dymondmonae Author
wrote...

4 years ago
I appreciate what you did here, answered it right Smiling Face with Open Mouth
wrote...

Yesterday
This helped my grade so much Perfect
wrote...

2 hours ago
Thanks
New Topic      
Explore
Post your homework questions and get free online help from our incredible volunteers
  1502 People Browsing
Related Images
  
 61
  
 1591
  
 361
Your Opinion
Who's your favorite biologist?
Votes: 608

Previous poll results: What's your favorite math subject?