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
What is the purpose of tostring() method in java?
Is java a digit method?
What is a copy constructor in java?
what is the final keyword denotes in java?
What are mutable classes?
How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?
What is flag in java?
Does java linked list allow duplicates?
Do we need to manually write Copy Constructor?
Is there any difference between synchronized methods and synchronized statements?
What is the use of default method in interface in java? Explain
What is substring 1 in java?
Explain the differences between abstraction and encapsulation?
What is 16 bits called?
How many java versions are there?