Question:

Which of the following will not return a value ?

Show Hint

In programming, distinguish between a function that returns "no value" (void) and a function that returns a "value of nothing" (null). \text{void} means there's no return mechanism, while \text{null} is an actual value that can be returned.
  • Null
  • Void
  • Empty
  • Free
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Step 1: Understand the context of the question. In programming languages like C, C++, Java, and C\#, functions or methods have a return type that specifies the type of value they send back after execution.
Step 2: Analyze the options.

(A) Null: This is a special value that represents the absence of a value or a reference to no object. A function \textit{can} return null.
(B) Void: This is a keyword used as a return type for functions that do not return any value. It explicitly means "returns nothing".
(C) Empty: This describes the state of a data structure (like an empty string "" or an empty list). It is not a type or a keyword that signifies no return value.
(D) Free: This is typically a function name (e.g., \text{free()}) used in memory management to deallocate memory. It is an action, not a return type.
Therefore, \text{Void} is the keyword used to indicate that a function will not return a value.
Was this answer helpful?
0
0