74.9k views
3 votes
Can a non-void method use the keyword return without returning a value? Explain your answer.

User Hwrd
by
5.9k points

1 Answer

2 votes

Answer:

False. A non void method must return something.

Step-by-step explanation:

No, a non-void method has return statement in it and it returns a value based on the return type in the method declaration and the implementation of that method. Every non - void method has to return a value depending on its declaration. A non void method should have a return statement in it. As it is a non - void method and has return statement in it, it returns a value based on the implementation of that method. If a void method contains return statement in it, the method exits.

User Maramal
by
5.0k points