Which of the following methods compile? (Choose all that apply)
methodA()
{ return;} methodB()
{ return null;} methodD()
{} methodD()
{ return 9;} methodE()
{ return 9.0;} methodF()
{ return;} methodG()
{ return null;} A, C, D.
Options A and C are correct because a void method is allowed to have a return statement as long as it doesn't try to return a value.
Options B and G do not compile because null requires a reference object as the return type.
void is not a reference object since it is a marker for no return type.
int is not a reference object since it is a primitive.
Option D is correct because it returns an int value.
Option E does not compile because it tries to return a double when the return type is int.
Since a double cannot be assigned to an int, it cannot be returned as one either.
Option F does not compile because no value is actually returned.