(java: method and text files): what is wrong with the following code? public sta
ID: 3623992 • Letter: #
Question
(java: method and text files): what is wrong with the following code?
public static char grade(int score)
{ a. File inFile = File("input.txt")
if (score >= 9) b. File inFile = new File("input.txt")
{ c. File inFile = File.open("input.txt")
return 'A'; d. File inFile = new File.open("input.txt")
}
else if (score >= 8) a. complication error
} b. invalid parameter types
c. a return statement may not be reaches
d. invalid return type
return 'B';
{
else if (score >= 6);
}
return 'C';
}
else if (score >= 4);
{
return 'D';
}
}
Explanation / Answer
I think you mean compilation error, not complication. Anyways it is compilation error because the code goes from if to else if to else if to else if to else if and then stops. A correct code needs to have somewhere to end but the code snip never has an "else" statement to end the conditions. Thus a compilation error will occur. So a. is correct answer.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.