About Question enthuware.ocajp.i.v7.2.1283 :
Posted: Sun Nov 16, 2014 11:34 am
The question is
The compiler will complain:
And the explanation for the third option, which isWhat is the correct declaration for an abstract method 'add' in a class that is accessible to any class, takes no arguments and returns nothing?
isabstract null add();
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: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.
Code: Select all
int m1{return null;}
Did I miss something?Type mismatch: cannot convert from null to int