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

Given:

and

and

Which three are true? (Choose three.)

    Correct Answer: C, F, I

    f1.foo(c) calls the foo() method on the f1 object, which is an instance of the Foo class. This method prints 'Bonjour le monde!', so f1.foo(c) prints 'Bonjour le monde!'. For f2.foo(c), even though f2 is declared with Foo type, the actual object is Bar. Therefore, the method in Bar with Collection argument 'Hello world!' will be executed; thus, f2.foo(c) prints 'Hello world!'. For b1.foo(c), the object is a Bar, and because the method being called has a Collection argument (ArrayList is a subtype of Collection), it matches the method defined in Bar with Collection argument, printing 'Hello world!'. Therefore, the correct options are those indicating these outputs: C, F, and I.

Discussion
cathDevOptions: CFI

Tested really CFI

d7bb0b2Options: CFI

C F and I are correct E is not correct

dillemanOptions: CFI

Tested, C F I is correct.

Ashan_OzlovOptions: CFI

Tested

[Removed]Options: CFH

E is incorrect because The reference type 'Collection' is what decides which method gets called.

[Removed]

Which cannot invoke a method with List parameter type.

StavokOptions: CEF

f1.foo(c) calls the foo() method on the f1 object, which is an instance of the Foo class. This method prints "Bonjour le monde!", so C is true.f2.foo(c) calls the foo() method on the f2 object, which is an instance of the Bar class. Since f2 is declared as a Foo object, the foo() method from the Foo class is overridden by the foo() method from the Bar class that takes a Collection argument. This method prints "Hello world!", so F is true.b1.foo(c) calls the foo() method on the b1 object, which is an instance of the Bar class. Since b1 is declared as a Bar object and the argument passed to the method is a List, the most specific version of the overloaded foo() method from the Bar class that takes a List argument is called. This method prints "Ola Mundo!", so E is true.

belal97Options: CDI

CDI correct

belal97Options: CEF

foo f1 = new foo(); => foo class has one method print hello world foo f2 = new bar(); f2 cant access overload method in bar so print ponjour bar b1 = new bar() ; b1 can access two method but we pass arrayList so print ola

KiraguJohn

b1 will take the foo with collection not the one with arrayList. Just tested