1z0-819 Exam QuestionsBrowse all questions from this exam

1z0-819 Exam - Question 85


Given:

Which is true? (Choose four.)

Show Answer
Correct Answer: ACEFG

The code provided has the following structure: an interface `Pastry` with a `getIngredients` method, an abstract class `Cookie` implementing `Pastry`, and two concrete classes `ChocolateCookie` and `CoconutChocolateCookie`. The code complies properly because: 1) Lines 6 and 9 are correct. The `ChocolateCookie` class can implement the `Pastry` interface indirectly through the `Cookie` abstract class. 2) The `CoconutChocolateCookie` class can override the `getIngredients` method with an additional parameter `int x`. This is method overloading, not overriding, which is allowed. Thus, the correct answer is that the compilation succeeds, as indicated in option G, and the error claimed in line 6 from option E, is indeed valid, as one cannot implement another class, they must extend it.

Discussion

10 comments
Sign in to comment
[Removed]
Aug 30, 2023

Only E is correct.

tmuralimanohar
Jun 29, 2023

Answer: E

StavokOptions: ABEF
Jul 18, 2023

A,B,E,F are correct

OmnisumemOptions: BE
Sep 11, 2023

I am sure B and E are correct. And G for sure is not correct. Other ..??? Very strange ...

[Removed]
Sep 27, 2023

E is correct. You do not implement another Class, you extend it.

Samps
Dec 28, 2023

Ony E is correct

Samps
Dec 28, 2023

Only E is correct

d7bb0b2
Jan 8, 2024

Only E, => cannot implements a class abstract or not

cathDev
May 15, 2024

interface Pastry{ void getIngredients(); } abstract class Cookie implements Pastry { } class ChocolateCookie implements Cookie { public void getIngredients(){} } public class CoconutChocolateCookie extends ChocolateCookie { void getIngredients(int x) {} public static void main(String[] args){ } } Only E is correct

ASPushkinOption: E
Jul 3, 2024

answer : E all classes are decalred with the default modifier so all of them are visible only within its own package for oveloaded methods access modifier can be changed so just one error with the implements on line 6