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

What string is utf8?

553


Explain heap sort?

705


What is the need of transient variables in Java ?

583


If a method is declared as protected, where may the method be accessed?

538


Why is core java important?

576






Write a program to print all permutations of string?

682


Do you know how to reverse string in java?

588


What does sizeof return?

563


What are the methods of object class ?

567


How do I enable java in safari?

554


What is string made of?

531


Is upper case in java?

536


What is the += operator called?

583


Explain different types of thread priorities ?

629


What is printwriter in java?

525