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.
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
b1 will take the foo with collection not the one with arrayList. Just tested
upvoted 1 times
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
cathDev
3 months agod7bb0b2
6 months, 1 week agodilleman
9 months, 2 weeks agoAshan_Ozlov
9 months, 3 weeks ago[Removed]
10 months, 2 weeks ago[Removed]
10 months, 2 weeks agoStavok
11 months, 4 weeks agobelal97
1 year agobelal97
1 year agoKiraguJohn
1 year ago