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

Given:

and

    Correct Answer: C

    In the given code, the class Foo has a private method a() returning 'Hello world!'. The class Bar extends Foo and overrides the method a() with protected visibility, returning 'Bonjour le monde!'. The class Baz extends Bar but does not override the method a(). When calling the b() method on instances of Foo, Bar, and Baz, the following will happen: - `new Foo().b()` will call Foo's b(), which calls Foo's private a(). So, it returns 'Hello world!'. - `new Bar().b()` will call Foo's b() (since b() is not overridden in Bar), which calls Bar's overridden a(), so it returns 'Bonjour le monde!'. - `new Baz().b()` will call Baz's b(), which calls Bar's overridden a(), so it returns 'Bonjour le monde!'. Thus, the output will be 'Hello world!', 'Bonjour le monde!', and 'Bonjour le monde!', matching option C.

Discussion
belal97Option: C

hello world hello world Bonjour le monde

StavokOption: C

Hello World! Hello World! Bonjour le monde

bardemk

NO ANSWERS CORRECT Tested Hello World Hello World Bonjour le monde

SebaGPOption: D

HELLO WORLD HELLO WORLD BONJOUR MONDE

d7bb0b2

Hello World! Hello World! Bonjour le monde NO ANSWERS CORRECT method private cannot override so exist a in foo when b in foo call a() really call a in foo no in bar