#include <stdio.h>
int n=3;
void main(int m)
{ m=n;
while(m>=1)
{
printf("OUG Tree\n");
return main(n--);
}
getch();
}
well this program calls main three times within itself prints OUG Tree 3 times
No. There can only be one main method, however you can declare new methods, and call them from the main method. Or you can use multi-threading, to simulate having multiple main methods.
I assume the question is about Java. How you call a method from inside the main method depends on whether this is an instance method or a static method. To call an instance method, you need to have a valid instance. Say foo is an instance of class Foo, which was created inside the main method. Then to call the instance method implode() use foo.implode() To call the static method bar() of class Foo, use Foo.bar().
At the time of developing jvm the development team by default make a only one method call i.e; 'main' method call in the jvm that's why when the call is loading into the jvm the jvm call the main method...and execution was starts..
No
We can't call a class. We always call a method in java.
method
There are no methods in C, and you should have only one main function.Methods are associated with a specific class, and there are no classes in c.
Every program requires an entry point. Main() provides the entry point in C.
Of course.
No, the reason is simple: A method marked as a static means, that you don't need create an instance (create an object with the 'new' operator) in order to use it. The main method is the entry point for a java application, therefor there is nothing after you call it. no one who can create an object of the type of your class and call the main method. So the jvm must call the main method with no object reference.
The main method is static because the JVM would be invoking this method as the starting point of execution. If this is like other normal methods, the JVM would have to instantiate an object of the class before it can call it. This is not possible because this is the starting point. If the main method is static the JVM can directly call this by specifying the class name.
we can call global variables in main method by using scope resolution operator(::) if local and global have same name for example int x=10; main() { int x=20; cout<<x; //x=20 cout<<::x; //x=10 }