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);
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.
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.
Duplicate default methods named calculatedSurfaceArea with the parameters (double, double) and (double, double) are inherited from the types Ellipse and Rectangle
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
...
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.
ASPushkin
3 weeks, 2 days agoASPushkin
4 months, 2 weeks agoRoxyFoxy
1 year, 2 months ago[Removed]
1 year, 3 months ago[Removed]
1 year, 3 months ago[Removed]
1 year, 4 months agogopu_azure32
1 year, 7 months agoStavok
1 year, 7 months agoMukes877
1 year, 7 months agoLondeka
1 year, 11 months agoTADIEWA
2 years ago