ADVANCED TOPICS IN COMPILER DESIGN
CODE GENERATION FOR OBJECT ORIENTED LANGUAGES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
0 VOID
|
|
PRINTF()
|
|
SCANF()
|
|
GETCH()
|
Detailed explanation-1: -When used as a function return type, the void keyword specifies that the function doesn’t return a value. When used for a function’s parameter list, void specifies that the function takes no parameters.
Detailed explanation-2: -The reason for the error/warning message is because a void function, by definition, does not return a value. When you include the return (0) statement, you are saying that the function returns a value of 0. This presents the compiler with a contradicting declaration and return. So, the compiler generates an error.
Detailed explanation-3: -In lieu of a data type, void functions use the keyword “void.” A void function performs a task, and then control returns back to the caller–but, it does not return a value. You may or may not use the return statement, as there is no return value.
Detailed explanation-4: -void: Java void keyword is used to specify that a method does not have a return value.