The answer is no. When you run something from the prompt (java XYZ) then the java executable will run the main method of whatever class you specify. If there is no main method then you will get an error.
Is this method a part of some class in the java API. Is it declared in some class of java API and we override that method in our class
Every Java application must contain a main method whose signature looks like this:
public static void main(String args)
When the Java interpreter executes an application (by being invoked upon the application's controlling class), it starts by calling the class's main method. The main method then calls all the other methods required to run your application.
If you try to invoke the Java interpreter on a class that does not have a main method, the interpreter refuses to run your program and displays an error message similar to this:
In class NoMain: void main(String argv) is not defined
From The Java Tutorial
The Java virtual machine starts up by creating an initial class, which is specified in an implementation-dependent manner, using the bootstrap class loader (�5.3.1). The Java virtual machine then links the initial class, initializes it, and invokes its public class method void main(String). The invocation of this method drives all further execution.
From JVM Specification 2nd ed. Section 5.2
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton