Monday, 8 August 2016

Q-3:-is it possible to write main() in multiple class of  .java file?

Ans:yes,it is possible to write the main() in multiple class.

FOR EX:-

                                                          demo.java

class hello

{

      public static void main(String[]args)

{
      System.out.println("hii hello");
}
}
class test
{

   public static void main(String[]args)

{
      System.out.println("hii test");
}
}
output:
1)compile the program
javac demo.java
2)To run the program
java hello
hii hello
2)to run the program using test class
java test
hiii test

  

1 comment: