PRACTICE / UNDERSTAND / REPEAT
Java practice question
Practice declarations with self-contained questions. Check your answer, then use the explanation to understand the reasoning.
1 questionAnswers explainedFree · no login
Try this question
Complete the method declaration so it returns an integer.
public ___ size() {
return 3;
}
Answer & explanation
Answer: int
The declared return type must match the returned value; `3` is an `int`.