exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 29 discussion

Actual exam question from Oracle's 1z0-819
Question #: 29
Topic #: 1
[All 1z0-819 Questions]

Given:

What prevents this code from compiling?

  • A. The calculateSurfaceArea method within Cylinder must be declared default.
  • B. Cylinder is not properly calling the Rectangle and Ellipse interfaces’ calculateSurfaceArea methods.
  • C. Cylinder requires an implementation of calculateSurfaceArea with two parameters.
  • D. The calculateSurfaceArea method within Rectangle and Ellipse requires a public access modifier.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ASPushkin
3 weeks, 2 days ago
Selected Answer: C
If a class implements two interfaces, both of which have a default method with the same name and parameter types, then you must resolve the conflict. You should provide "conflict default" method in class and either implement your own greeting, or delegate to one of the conflicting methods, like this: Rectangle.super.caculateSurfaceArea(majorR, minorR);
upvoted 1 times
...
ASPushkin
4 months, 2 weeks ago
Selected Answer: C
If a class implements two interfaces, both of which have a default method with the same name and parameter types, then you must resolve the conflict. You should provide "conflict default" method in the class. There is a case with nearer definition/ For example public interface Point { default double calculateSurfaceArea(double, double) { ... } } public interface Rectangle extends Point { } public interface Ellipse extends Point { default double calculateSurfaceArea(double, double) { ... } } public class Cylinder implements Ellipse, Rectangle { } new Cylinder().calculateSurfaceArea(double, double) executes Ellipse method because of nearer definition.
upvoted 1 times
...
RoxyFoxy
1 year, 2 months ago
Selected Answer: C
The two interfaces have default methods, so if they didn't have the same name, Cylinder would not have to call any of them (because they already have a default implementation), so B is not correct. As the two methods in the two interfaces have the same name, the class that implements them must define its own implementation, so C is correct.
upvoted 3 times
...
[Removed]
1 year, 3 months ago
Selected Answer: C
Tested in compiler. C is correct. It compiles when having only one method called calculatedSurfaceArea with two parameters in the child class.
upvoted 1 times
[Removed]
1 year, 3 months ago
Or wait, when reading the options again I guess it makes B correct..
upvoted 1 times
...
...
[Removed]
1 year, 4 months ago
C is correct. As a class implementing 2 interfaces with same(same signature) default method will cause a compile error.
upvoted 1 times
...
gopu_azure32
1 year, 7 months ago
B is correct
upvoted 1 times
...
Stavok
1 year, 7 months ago
Selected Answer: C
Duplicate default methods named calculatedSurfaceArea with the parameters (double, double) and (double, double) are inherited from the types Ellipse and Rectangle
upvoted 1 times
...
Mukes877
1 year, 7 months ago
Selected Answer: C
C is correct because two same default methods create conflict for the compiler.
upvoted 2 times
...
Londeka
1 year, 11 months ago
C is the correct answer
upvoted 2 times
...
TADIEWA
2 years ago
B is correct if a method implements two interfaces with same method signatures it has to provide an implementation to avoid conflict , same applies to abstract methods
upvoted 3 times
...
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago