Solved

Which of the Following Would Cause an ArrayIndexOutOfBounds Error

Question 25

Multiple Choice

Which of the following would cause an ArrayIndexOutOfBounds error?


A) public boolean setElementOfX(int index, int val) {
if(index >= 0 && index < x.length) {
x[index] = val;
return true;
} else {
return false;
}
}
B) public static void main(Strin[] args) {
String inputFileName;

if (args.length > 0)
inputFileName = args[0];
else
inputFileName = "Phone.dat";
}
C) for (int i = 0; i
x[i] = i + i;
D) for (int i = 0; i <= x.length; i++)
x[i] = i * i;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions