is it possible java can have two main(),1st is super class 2nd is subclass fasion?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gunapala cn
    New Member
    • Feb 2012
    • 1

    is it possible java can have two main(),1st is super class 2nd is subclass fasion?

    ............... ............... ............... ............... ............... ............... ............... .............
  • neeraj0708
    New Member
    • Feb 2012
    • 21

    #2
    Hi,

    Yes, It is possible. JVM only find the main class of saved file name.
    for example:

    class A{

    public static void main(String args[]){
    A a=new A();
    System.out.prin tln("A");
    }
    }
    class B extends A{
    public static void main(String args[]){
    B b=new B();
    System.out.prin tln("B");
    }
    }
    If this program will save by name A.java then main method of class A will get call. or if saved as B.java then B class main();

    Comment

    Working...