javascript
Brief description  about Online courses   join in Online courses
View Santosh Kumar Mohanty 's Profile

main method

Respected Sir,
1.Can We Overload A main Method?
2.Can We Write A Programme Without Using The Main() Method ?


Thank You Sir
Asked by Santosh Kumar Mohanty | Dec 15, 2010 |  Reply now
Replies (2)
View arun kumar das 's Profile
HI

1: Yes: we can overload the main() because overloading is the compile time polymorphism, we can put main() with different type of argument in main.
for Exp.
public class MainOverload{

public static void main(){
System.out.println("I am main method without any parameter!");
}

public static void main(String[] strArgs){
main();
}
}


2: Yes we can write a program without using main(), use of static block.


java teacher
Dec 16, 2010
View nagaraju chunchula 's Profile
1. NO- we can not overload the main method because JVM does not know that which main method to execute.

2. YES- we can write a program with out main() method. By writing static block if u want program replay me i send you

Dec 15, 2010