Advertisements
Advertisements
Question
Assertion: The return statement enables the exit of the program control from the current method.
Reason: If a method’s return type is void, it can still contain return 0 statement to return nothing.
Options
Both Assertion and Reason are true and Reason is the correct explanation for Assertion.
Both Assertion and Reason are true but Reason is not the correct explanation for Assertion.
Assertion is true and Reason is false.
Both Assertion and Reason are false.
MCQ
Assertion and Reasoning
Advertisements
Solution
Assertion is true and Reason is false.
Explanation:
Assertion is True: The
return statement is a control transfer statement. Its primary job is to stop the execution of the current method and transfer the program control back to the caller (the point where the method was invoked).Reason is False: In programming (like Java or C++), a
void method is explicitly defined as a method that does not return any value.- If you write
return 0;, the compiler expects an integer return type, notvoid. - In a
voidmethod, you can only usereturn;(with no value) to exit the method early. Usingreturn 0will cause a compilation error.
shaalaa.com
Is there an error in this question or solution?
2025-2026 (March) Official Board Paper
