I have the following classes
The interface:
public abstract class MyAbstractClass
{
public abstract boolean checkSomething();
}
The class inheriting the abstract class:
public class MyClass extends MyAbstractClass
{
public boolean checkSomething()
{
return true;
}
}
When I create MyClass in eclipse the checkSomething() method is created automaticly but with false as the default return value. Is there a way to specify in an abstract method definition what the default return type shoud be?
No, there's no such thing as a "default return value" in Java. Each implementation should decide that for itself - it's just the method templating that Eclipse uses which happens to have picked false. Given that you should be replacing the method body anyway, I don't see this as much of the problem.
If a default implementation of "just return true" is reasonable, it sounds like
checkSomething
shouldn't be abstract in the first place - that's where the default implementation would live, and be overridden by classes wanting to provide more specific behaviour.