170 questions
0 votes
2 answers
109 views
Interface overriding extending functional interface method as default and having an abstract method works abruptly
@FunctionalInterface interface StringConsumer extends Consumer<String> { @Override public default void accept(String s) { System.out.println(s.toUpperCase()); } void ...
0 votes
1 answer
39 views
default method executed instead of implementation
When calling findBySubstring() from ArticleAutocompleteServiceImpl - default method of interface is executed instead of implementation. Is it because of generics? What did I do wrong? How to keep this ...
1 vote
1 answer
273 views
Java 17: MenuIterator is not abstract and does not override abstract method remove() in java.util.Iterator
I'm getting the following error while implementing the java.util.Iterator interface in my class: java: MenuIterator is not abstract and does not override abstract method remove() in java.util.Iterator....
1 vote
1 answer
152 views
Override Object methods inside interface using default methods- Misleading error
Question: Need to understand why in case of Program 1 getting this misleading error, but in Program 2 it gives correct error? Also why unlike toString(), equals(Object), and hashCode(), overriding ...
2 votes
0 answers
60 views
VerifyError on Kitkat when code explicitly calls a default method
When instantiating a class that has code to explicitly call a default method for an interface that it implements, a java.lang.VerifyError is thrown. This happens on Kitkat (API 19), but Lollipop and ...
0 votes
2 answers
1k views
How can I write a junit test case for default methods of interface with zero lines of code
How can I write a junit test case for default methods of interface with zero lines of code as mentioned below : public interface A{ default void method1(){ } }
0 votes
1 answer
356 views
can abstract method do System.out.println?
I am a beginner in Java. I have a question about the abstract method in Interface. Is the following sampleMethod() an abstract method? My understanding is that it is not an abstract method due to ...
0 votes
1 answer
68 views
Selecting default implementation from indirectly inherited Interface not working
I have 4 Classes that look like this: public interface Foo<T> { ... default boolean isEmpty() { return false; //dummy value real implementation is not relevant for the problem } } public ...
5 votes
0 answers
46 views
Why is interface default method shadowed by parent private method? [duplicate]
I don't understand why an IllegalAccessError exception is thrown from the example below. The method foo() in Parent cannot be inherited by Child, because it is private. But trying to call the default ...
1 vote
1 answer
163 views
Class inheriting same method from two different interfaces and a single default implementation won't compile
I have stumbled upon a strange issue working with default methods. Consider this situation: interface A { int method(); } interface B { default int method() { return 1; } } class ...
5 votes
2 answers
309 views
What is the point of the Functor -> Applicative -> Monad hierarchy [duplicate]
What is the point of making Functor a super class of Applicative and Monad. Both Applicative and Monad immediately imply the only implementation of Functor that abides by the laws as far as I can tell....
2 votes
1 answer
3k views
OpenAPI generator returns 501 for implemented method
I've generated rest api with openAPI generator maven plugin and I've overridden the default method from MyApiDelegate interface, but POST request on /endpoint provides 501 NOT IMPLEMENTED as if I hadn'...
0 votes
1 answer
396 views
Is it possible to implement native methods in interfaces?
You often hear that methods in an interface have no implementation. However, in Java 8 it became possible to implement the default methods. But I'm interested. Was and is it possible to implement ...
1 vote
1 answer
272 views
Override DefaultGroovyMethods method
Is there a way to easily override toSet(Collection<T> self) method from DefaultGroovyMethods? Its implementation uses HashMap public static <T> Set<T> toSet(Collection<T> self) ...
0 votes
0 answers
94 views
cannot call default method of parent interface using super [duplicate]
interface WithDefinitionsInter { default void definedMeth() { System.out.println("inside interface"); } } class WithDefinitionsImpl implements WithDefinitionsInter { ...