Case 1
  • Overloading of the main method is possible but JVM will always call String[] argument main method only.
  • The other overloadd method we have to call explicitly then it will be executed just a normal method call.
  • classTest{
public static void main(String [] args){
System.out.println(String[] args);
}
Overload method
public static void main(String [] args){
System.out.println(int[] args);
}
}
Output: String[]

Case 2
Inheritance concept applicable for the main method. While executing the child class if child class doesn’t contain main method then parent class main method will be executed.
class P{
public static void main(String[] args){
System.out.println(“parent main”);
}
class C extends P{
}
}
Save case 2 program p.java
and compile case 2 program Javac P.java
If i am trying to compile case 2 program than 2 dot class file will be generated first p.class and second one c.class
now run
Java P
Output: prarent main
Now run  child class Java C
Output: parent main

Case 3
It seems overriding concept applicable for main method but it is not overriding it is method hiding.
class P{
public static void main (String [] args){
system.out.println(“parent main”):
}
}
class c extends P{
public static void main( String[] args){
System.out.println(“child main”); }
}
now run parent class
Java P
Output: prarent main
Now run  child class
Java C
Output: child main

Note: For main method inheritance and overloading concepts are applicable but overriding concept is not applicable instead of overriding method hiding concept is applicable.