why main() method should not return any value

Answers were Sorted based on User's Feedback



why main() method should not return any value..

Answer / nadeem khokhar

execution starts from the main function. no function can call it, which means no function can save the returned value from main. then why should we take its return type as we can not use that any where! i do agree to jhill123 that in C we write int main instead of void main, it is used for exception handling.

Is This Answer Correct ?    4 Yes 2 No

why main() method should not return any value..

Answer / jhil123

It is possible if we declare main() function return value
as void. This is because the default return value of main
function in C is int and if one declares it as void it
results in mismatch in declaration and so cannot be
declared as void.

Is This Answer Correct ?    6 Yes 7 No

Post New Answer

More Programming Languages AllOther Interview Questions

Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. So 3 2 7 10 should return 13 (sum of 3 and 10) or 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)

0 Answers   Amazon,


Difference between HTML and DHTML?

0 Answers  


why applet is introduced?

1 Answers  


why Java is not purely object oriented?

9 Answers   Persistent,


how we define two jobs have same name??is it exist??

0 Answers   CTS,






What are the other ways to create an object with out calling new keyword in java?

2 Answers   HCL,


pleasew define carrier scope in abap (sap).

0 Answers  


what is the main usage of an abstract keyword?please follow the program class A { void display() { System.out.println("hai"); } void print() { } } class B extends A { void print() { System.out.println("Hello"); } } In this program i was gives the implementation of print() according to my requirements in subclass.And there is no definition in superclass then why we can use abstract keyword before a method that i want to gives definition in other classes,is any mistakes in the above usage of method?

0 Answers  


Bonjour, svp je veut voir comment envoyer un mail en java et comment changer le droit d'accé d'un fichier en java: de lecture en lecture/écriture et merci d'avance ;)

0 Answers  


how many languages .net is supporting now?

2 Answers  


Given a arbitrary pointer to an element in a singly linked list?what is the time complexity for its deletion .

1 Answers   Hughes,


is try block possible without catch block?

3 Answers  


Categories