Is it possible to override the main method in Java

static method can be overide.it is should be possible. example

class madd { 
public static void main(String args[]) {


}


public class mohit extends madd { 
public static void main(String args[]) { 
System.out.println("HELLO"); 


}

compile succefully and run also.then output will be HELLO

This perception is wrong.
In actual, static methods are hidden, not overriden. The above example, actually hides the derived method implementation of main() from base class method implememntation. This is hiding. It will compile, as it is syntactically correct but as concept wise, this is hiding. 

Comments