All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.
What is the correct declaration for an abstract method 'add' in a class that is accessible to any class, takes no arguments and returns nothing?
And the explanation for the third option, which is
abstract null add();
is
A method that is not supposed to return anything must specify void as its return type. null is not a type, though it is a valid return value for any type.
I think null is only a valid return value for any reference type. You can't return null as a primitive value. If you try to do this:
your question: what is the correct declaration for an abstract method 'add' in a class that is accessible to any class, takes no arguments and returns nothing?
the first option "public void add();" (in my bank of question at least) ...I guess is correct in the methos would be declared in an Interface isn't it?
public Interface myinterface
{
public void add();
}
this method would be by default public and abstract ... so in this case your question would have 2 correct answers
mutley wrote:your question: what is the correct declaration for an abstract method 'add' in a class that is accessible to any class, takes no arguments and returns nothing?
the first option "public void add();" (in my bank of question at least) ...I guess is correct in the methos would be declared in an Interface isn't it?
public Interface myinterface
{
public void add();
}
this method would be by default public and abstract ... so in this case your question would have 2 correct answers
Sorry , rading better the question , "in a class" poped up ...so no interface there .