answersLogoWhite

0

Why void is restriction in java main function?

Updated: 8/16/2019
User Avatar

Wiki User

15y ago

Best Answer

becoz the main program doesnot return any value to the os.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why void is restriction in java main function?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is psvm in java?

public static void main


What is a main function in java?

the main function or main method is the first method that gets invoked when you try to run a java application. Any class that has a main method can be executed in a standalone fashion. A typical main method would look like below: public static void main(String[] args) { … // code goes here }


Why should the java main method has the return type as void?

A void method is one that returns no value. The Java main() method is the first method to be called, therefore it doesn't need to return a value to another Java method, therefore it is declared as void. If something needs to be returned to the operating system, this is done differently, not by "returning a value" in the sense of Java.


Can return statement be in a void method in java?

the main method in java is the client code therefore doesn't return any values Unlike languages like C/C++, the user doesn't specify an error return code by returning from the main method. Instead they should use System.exit(code) to do this. If the Java main method returns, the default code of zero is returned.


What is the difference between main function in C java?

// C int main(int argc, char** argv) { return 0; } // Java class MainClass { public static void main(String[] args) { } } Differences: * Java main method must be in a class; C has no class, so no such requirement exists. * Both accept an array of command-line args. * ** Java arrays know how long they are; C does not and thus the main function must have an additional parameter to know the length of the array. * The Java main method has a specific format; the C main function seems to be allowed to differ. * ** The C main function seems to be able to accept different numbers of arguments and have different return types (assuming the implementation allows it).


Can you overwrite main function in java?

You can not overwrite a static method in Java,and 'main' is a static method.so,you can't overwrite the 'main'.


What is the default return type of a function?

The normal exit of program is represented by zero return value. If the code has errors, fault etc., it will be terminated by non-zero value. In C++ language, the main() function can be left without return value. By default, it will return zero. To learn more about data science please visit- Learnbay.co


Where void main is called in c?

main() is the function from where the execution starts.


What does a void method do?

In Java, this keyword is used to specify that the method has no return value.


What is the error in exception handling in java with example?

class Demo { public static void main(String s[]) { System.out.println("hello java frm Demo"); } } class Demo1 { public static void main(String s[]) { System.out.println("hello java frm Demo1"); String z={" "}; Demo.main(); } }


The name of a java programm file must match the name of the class with the extensionjava its true or false?

yes it is true becoz the class contain the main function or you can say that it is necessory to define the main function into the class name ex------> class test { int a=10; int b=20; void sum() { int c=a+b; System.out.println(c); } } class test12 { public static void main(String s[]) { test t=new test(); t.sum(); } } in the above example class test12 contain the main function so the file name is as well as test12.java.


Why use the void display()?

void display is the function name in which we want to perform some task or it might be to display something. But it has got its residence in the main() function that means that function's inputs are being supplied from the main(). void doesn't return anything so function call is made in main() which doesn't return anything back to it.