Can u overload main()method.Give with example.

Answer Posted / kuldeep

yes it is possible in java but jvm call only one main()
method. for eg.

class test
{
public static void main(String []ar)
{
System.out.println("his is 1 st main() method");
}

public static void main(String ar[],String []st)
{
System.out.print("overloaded main() method");
}
}

but o/p of this program is: 1st main() method statement is
display. but why its ans. is at complile time String ar
argument contain one argument it is class name for making a
class file or byte code file. 2 arg store the one class
name it is not possible

Is This Answer Correct ?    9 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In java, what is the difference between method overloading and method overriding?

795


What is math in java?

808


What are the different types of collections in java?

722


what is meant by HQL?

820


State two differences between C and Java.

931


Why singleton class is used in java?

798


How hashmap works in java?

785


What is meant by tab pans?

843


What is the difference between throw and throws in java?

761


Give differences between Quicksort & Mergesort. When should these sorts be used and what is their running time?

764


How are java objects passed to a method and what are native methods?

808


What is a jagged array in java?

768


Can we write method inside a method in java?

738


Which is best ide for java?

764


What is assembly language?

719