Given:
and
and
Which three are correct? (Choose three.)
Given:
and
and
Which three are correct? (Choose three.)
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!.
DEH is correct
Answer: DEH
The correct answer is D, E and H
The correct answer is D, E and H
D,E,H are correct
because the reference type(Base class) determines which method will be called so overridden method will be called by the compiler.