PRACTICE / UNDERSTAND / REPEAT

Java: Declarations

Practice declarations with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

15 questionsAnswers explainedFree · no login
Question 1 of 15
Declarations · Code recallQuestion link ↗

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`.