[Solved]Java Interpret Code 1 Int Arr 9 1 0 8 5 7 8 2 Int Sum 0 Int 1 Arrlength 0 2 Sum Arr System Q37063746
Java. How do I interpret this code?
1.
int[] arr = { 9, -1, 0, 8, -5, 7, 8, 2 };
int sum = 0;
for (int i = 1; i < arr.length 0; i *= 2){
sum += i*arr[i];
}
System.out.printf(“%d%n”, sum);
2.
// assume the file opens successfully
try (PrintWriter fileOut =
new PrintWriter(“fishing.txt”)){
for (int i = 0; i < 3; i++)
fileOut.println(“a fish “+ i +
” in the hand”);
fileOut.close();
} catch (FileNotFoundException ex) {
System.out.println(“File not found. ” + “Check the file name!”);
System.exit(0);
}
3.
public classFinalExample {
publicstatic void main(String[] args)
{
double x = 10;
double y = 13;
double z = -4.4;
System.out.printf(“%.1f%n”, x);
System.out.printf(“%.1f%n”, y);
System.out.printf(“%.1f%n”, z);
z = f(x, y);
System.out.printf(“%.3f%n”, z);
}
publicstatic double f(double x,
double y {
x += (2*y);
y -= 6;
return (y – x);
}
}
Expert Answer
Answer to Java. How do I interpret this code? 1. int[] arr = { 9, -1, 0, 8, -5, 7, 8, 2 }; int sum = 0; for (int i = 1; i < arr.le... . . .
OR

