Identify the syntax errors in the following code. and explain why? Select all th
ID: 3725333 • Letter: I
Question
Identify the syntax errors in the following code. and explain why? Select all that apply.
public static short jumpToYear (short... years, string Doctor)
{
short yearStart = years[0];
for (short i : years)
if (i < yearStart)
yearStart = i;
return yearStart;
}
assignment to yearStart
the function header
the loop header
comparison of yearStart
initialization of yearStart
return statement
Answers:assignment to yearStart
the function header
the loop header
comparison of yearStart
initialization of yearStart
return statement
Explanation / Answer
public static short jumpToYear (short... years, string Doctor)
{
short yearStart = years[0];
for (short i : years)
if (i < yearStart)
yearStart = i;
return yearStart;
}
The correct option is A. (The function Header)
Explanation:
here is the correct function header and code.
public static short jumpToYear(short years[], String Doctor)
{
short yearStart = years[0];
for(short i : years)
if (i < yearStart)
yearStart = i;
return yearStart;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.