Search This Blog

Monday, February 6, 2012

Main method overriding

[quote=dlorde]Why would you want to? The main method is a static entry point for running an application, it has no place in the OO hierarchy.

actually when i am reding a tutorial i got this doubt. i browse for this. i get tht u can overload the main methond. but i didnot get the correct answere for overriding main method. some body saying it is possible with example and some body saying not possible because it is static. plz check this example and clear my doubt.

class Checkmain
{

public static void main(String args[])
{
System.out.println("helloCheckmain string main ");
}
}

class Checkmain1 extends Checkmain
{
public static void main(String args[])
{
System.out.println("helloCheckmain1 string main ");
}
}

public class Main
{
public static void main(String args[])
{
String S[]=new String[10] ;
System.out.println("******string main**********");
int q=10;
main(q);
Checkmain.main(S);
Checkmain1.main(S);
}

public static void main(int a
{
String S[]=new String[10] ;
System.out.println("000000000 int main 0000000000");
Checkmain.main(S);
Checkmain1.main(S);
}
}


First clear my doubt after i will think abt use of this feature.

No comments:

Post a Comment