Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 158

Given:

and

Which is the correct implementation of the getRatings method in the Football subclass?

    Correct Answer: D

    To correctly implement the getRatings method in the Football subclass while calling the base class's method, the appropriate approach is to use super.getRatings(). This syntax ensures that the method from the superclass (Sports) is invoked, while the subclass (Football) can still utilize its own fields in the method implementation. The other options either suggest incorrect syntax (like new.getRatings() or public.getRatings()) or imply direct field access without calling the superclass method.

Discussion
OmnisumemOption: D

AI answered: The correct implementation of the getRatings method in the Football subclass is: D. The subclass getRatings method uses super.getRatings() to call the base class method but uses its own named fields in the implementation. Explanation: Using super.getRatings() allows the Football subclass to call the getRatings method defined in the Sports superclass. The subclass can then use its own named fields and logic in the implementation of the method while still leveraging the functionality provided by the base class.

d7bb0b2Option: D

D, to call base method of super classs, super.method is used

[Removed]Option: D

D is syntatically correct. The other ones make no sense