Can a java program have 2 main methods?



Can a java program have 2 main methods?..

Answer / Sonoo Kumar Kasaudhan

No, a Java program can only have one public static void main(String[] args) method. Multiple main methods are not allowed.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Can you create an object of an abstract class?

1 Answers  


Can we sort hashset in java?

1 Answers  


What is a method signature java?

1 Answers  


interface X{ void m1(); void m2(); } class Child2 extends Object implements X { public void m1(){ System.out.println("Child2 M1"); } public void m2(){ System.out.println("Child2 M2"); } } public class ParentChildInfterfaceDemo { public static void main(String[] args){ X x = new Child2(); X x1 = new Child2(); x.m1(); x.m2(); x.equals(x1); } } Will the above code work? If yes? Can you please explain why the code x.equals(x1) will work as the equals method is called on interface reference vaiable?

2 Answers  


How java is similar to c?

1 Answers  


What is static block?

1 Answers  


What is the difference between the ">>" and " >>>" operators in java?

1 Answers  


what is domain object

1 Answers  


What's the base class of all exception classes?

1 Answers  


Is class is a data type?

1 Answers  


What is null statement?

1 Answers  


Can a double value be cast to a byte?

3 Answers  


Categories