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

Given:

and

and

Which three are correct? (Choose three.)

    Correct Answer:

    In the given code, class Bar extends class Foo. Bar has two overloads of the foo method: one that takes a Collection and another that takes a List. foo(Collection arg) in Bar overrides foo(Collection arg) in Foo. foo(List arg) in Bar is an overloaded method, but not an overridden one. Since List is a subinterface of Collection, overload resolution comes into play. Given the instantiation combinations and the argument type being List, method resolution adheres to Java's method resolution rules. For f1.foo(li), since f1 is a Foo instance, Foo's method foo(Collection) is called, printing 'Bonjour le monde!'. For f2.foo(li), since f2 is a Bar instance, Bar’s method foo(Collection) overrides Foo's method, and 'Hello world!' is printed. For b1.foo(li), since b1 is of type Bar, it matches the overloaded foo(List) in Bar, printing 'Hola Mundo!'. Therefore, the correct answers are: f1.foo(li) prints Bonjour le monde!, f2.foo(li) prints Hello world!, and b1.foo(li) prints Hola Mundo!.

Discussion
StavokOptions: DEH

DEH is correct

tmuralimanoharOptions: DEH

Answer: DEH

Mukes877Options: DEH

The correct answer is D, E and H

ObaltOptions: DEH

The correct answer is D, E and H

d7bb0b2Options: DEH

D,E,H are correct

Mukes877

because the reference type(Base class) determines which method will be called so overridden method will be called by the compiler.