Given the following method, what do we need to fix?
Public static String getPerformance(char grade)
{
If (grade == 'A' || grade == 'B' || grade == 'C' || grade == 'D'
|| grade == 'F')
{
String desc = "";
Switch (grade)
{
Case 'A': desc = "Excellent"; break;
Case 'B': desc = "Good"; break;
Case 'C': desc = "Mediocre"; break;
Case 'D': desc = "Weak"; break;
Case 'F': desc = "Bad"; break;
}
}
Return desc;
}
A) Change the parameter variable type to String
B) Add a local Boolean variable definition to test the input
C) Add return statements inside the switch branches
D) Move the definition of the local variable desc before the if statement
Correct Answer:
Verified
Q70: Which of the following options describes the
Q71: Given the following method:
Public static boolean isMagic(int
Q72: Given the following method that checks for
Q73: An effective technique for understanding the subtle
Q74: A temporary method that is used to
Q76: In the following code snippet, what is
Q77: Given the following method, what method call
Q78: Which of the following options represents the
Q79: For a program that reads three letter
Q80: What is incorrect in the following code
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents