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

Given:

Which is true? (Choose four.)

    Correct Answer: E, G

    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
[Removed]

Only E is correct.

[Removed]

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

OmnisumemOptions: BE

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

StavokOptions: ABEF

A,B,E,F are correct

tmuralimanohar

Answer: E

ASPushkinOption: E

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

cathDev

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

d7bb0b2

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

Samps

Only E is correct

Samps

Ony E is correct